0
I’m asking a question in Rio Tag replacement, that one has to replace one name with another but I’m not succeeding, I can only with normal names without characters
My code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char nome[] = "Stack overflow";
char *ptr;
char aux[900];
int cont = 0;
ptr = strtok(nome, " ");
while(ptr != NULL)
{
if(cont == 0)
{
if(strcmp(ptr, "overflow") == 0)
{
strcpy(aux, "certo");
}
else
{
strcpy(aux, ptr);
strcat(aux, " ");
}
cont++;
}
else
{
if(strcmp(ptr, "overflow") == 0)
{
strcat(aux, "certo");
}
else
{
strcat(aux, ptr);
strcat(aux, " ");
}
}
ptr = strtok(NULL, " ");
}
puts(aux);
}
Where’s the part you play
tag
or nottag
? Personally I find it easier to iterate the characters normally instead of usingstrtok
, and generate an output buffer with just the right characters, and then just show– Isac
As I would change name, I tried to do a by passing the sentence with what was to be changed but other parts of the text were changed
– rafael marques