0
So, I have to remove a word from a String, already add with this code:
printf("Digite o nome: \n");
scanf("%s", &temporaryVector);
getchar();
lettersName = strlen(temporaryVector);
temporaryVector[lettersName] = ';';
temporaryVector[lettersName + 1] = '\0';
lettersName = lettersName + 2;
name = (char*)malloc(sizeof(char) * (lettersName));
if (!name) {
printf ("Erro, não foi possível alocar espaco.");
return -1;
}
strcpy (name, temporaryVector);
oldSize = lettersName + oldSize;
firstAcess++;
} else {
printf("Digite o nome: \n");
scanf("%s", &temporaryVector);
getchar();
lettersName = strlen(temporaryVector);
temporaryVector[lettersName] = ';';
temporaryVector[lettersName + 1] = '\0';
lettersName = lettersName + 2;
oldSize = lettersName + oldSize;
name = (char*)realloc(name, oldSize);
if (!name) {
printf ("Erro, não foi possível alocar espaco.");
return -1;
}
strncat (name, temporaryVector, oldSize);
printf("%s\n", name);
}
At the end of each word I add one ;
to separate. I just don’t know how to delete a specific word now.
the answer is good, but to score.. you pasted one
else
right after the line offirstAcess++;
.. thatelse
is lost (not associated with aif
); would probably have build error– rLinhares