How to extract a word between , and =?

Asked

Viewed 45 times

0

Supposing I had a word:

char[1000]={"ALGUMA COISA,ALGO=TESTE,FIM"};

The word before = and = itself are optional in the sentence;

How do I store the SOMETHING word of the phrase in a variable?

The code below is what I tried, however, is not working:

#include<stdio.h>
#include<string.h>

 int main(){
char linha[1000]={"ALGUMA COISA,ALGO=TESTE,FIM"};`
char personagem[1000];
int ww=0;
int w1=0;
 int je=0;
                while(linha[w1]!='\0')
                {
                    if(linha[w1]=='=')
                    {
                        for(ww=w1;ww>0;ww--)
                        {
                            personagem[je]=linha[ww];
                            je++;
                        }
                    }
                    w1++;
                }
                personagem[je]='\0';
} 

Assuming w1 is the position found "=";

  • 1

    https://code-reference.com/c/string.h/strtok

  • @Magichat this is a working prototype, but in theory I opened the phrase all manually with loops... The only word I’m not getting is this... would you know how to do by looping? Strtok and Strtok wouldn’t work in this case I believe.

  • 1

    What is an MVP?

  • @Magichat related to entrepreneurship: https://pt.wikipedia.org/wiki/Produto_viável_mínimo (Minimum Viable Product) or you may be talking about Microsoft Most Valuable Professional https://en.wikipedia.org/wiki/Microsoft_Most_Valuable_Professional, if the latter is the case (I don’t know why the question came up, perhaps due to some previous deleted comment) is not something you will conquer by studying and related, is a title for active in communities, a kind of recognition so that collaborates very much with good knowledge in open communities about microsoft technologies.

  • He told me that it was a minimum verifiable example the "p" I do not remember, like mvp here from the only meesmo heheh

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.