Get a string to a new one ignoring words from another string in C?

1

Let's say I have a certain string called a string [1024], which looks something like this:

char cadena[1024] = "int/0void/0/main/0a/0";

Afterwards, I have a two-dimensional arrangement where I stored some words

char palres[20][10]={ "int", "main", "void" };

Let's say that I have a new string called variables[10][10] where I want to store all the words that are not in palres. In this case "a" .

What should I do or what function should I google?

First I used a cycle of while where the lines of the string were added (until x was 20 and inside a

            if((strcmp(cadena, palres[x]))==0){
            Break;
             }
             Else{
             strcpy(cadena, palres[x]);
              }
    
asked by Piranha 17.06.2017 в 16:30
source

1 answer

0
  

Note: you are missing one (") in the pallet assignment.

the logic itself is fine the process would be something like this:

int o = 0;
for(int i=0; i<20 ;i++){
    if(!strcmp(cadena, palres[i])==0){
        strcpy(variables[o],palres[i]);
        o++;
    }
}
    
answered by 17.06.2017 в 19:22