-1

so I've viewed multiple threads here now on this site about comparing my char array to a string or something of that sort with things like strcmp and strstr however whenever I compiled it, I got the error:

warning: incompatible implicit declaration of built-in function 'strstr' [enabled by default]

and honestly I have no idea what this means. I'm relatively new to C...

So here's my code:

int main(){

  FILE * fPointer;
  fPointer = fopen("test.txt", "r");

  char action[10];
  char num[100];
  char* s;

  while(fscanf(fPointer, "%s", action) != EOF){
    s = strstr(action, "JUMP");
    if(s != NULL){
      puts("Jump");
    }else{
      puts("Don't Jump");
    }
  }

  fclose(fPointer);

} 

I've tried a few other things, but none of them worked out. My text file has a bunch of actions:

JUMP 4
CRUNCH 7
SITUP 8

and other similar things like that. I wanted the while loop to scan for each action, and then compare it to whatever to see if action is = to "jump" etc, etc, and if it is, then scan the number to tell me how many times to do each action.

Can someone help me with this? Thanks so much!

Speakmore
  • 69
  • 2
  • 11
  • Please provide a [mcve]. The code as such lacks the headers. – too honest for this site Oct 24 '16 at 01:57
  • See: http://stackoverflow.com/questions/977233/warning-incompatible-implicit-declaration-of-built-in-function-xyz – Martin Oct 24 '16 at 02:28
  • Any time you use a library function, read the documentation (`man function_name` if you're on a Unix-like system). It should tell you how to call it and, most importantly in this case, what header you need to `#include`. – Keith Thompson Oct 24 '16 at 03:12

1 Answers1

0

You haven't included the proper header.

#include <string.h>
MarcD
  • 588
  • 3
  • 11