Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22093

SOLVED: GCC Compare String IF else ( A way to verify that you have written a certain word )

$
0
0

I'm learning at GCC and while I was trying various solutions to verify the entry of a certain word, IF Word = Word {do something;}It seems that in C it cannot be done directly and so I tried this solution that seems to work:

#include <stdio.h>#include <string.h>int main(){    int CClose = 0;    int VerifyS = 0;    char PWord[30] ={'\0'};    do {        printf("\n Type a word: ");        scanf(" %s", &PWord);        VerifyS = strncmp(PWord, "exit", 4);        if (!VerifyS){ CClose = 1;}else{ printf("\n The Word is:%s", PWord);}    }while (CClose != 1);    return 0;       }

I wanted to know if there is another way to do the same thing.Thank you.


Viewing all articles
Browse latest Browse all 22093

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>