Error: Assignment makes pointer from Integer without a cast… in C Prog

后端 未结 2 668
轻奢々
轻奢々 2021-01-27 13:31

I get this error whenever i run the program \" Assignment makes pointer from Integer without a cast\". My code is written below.... Please help... Thankx

struct          


        
相关标签:
2条回答
  • 2021-01-27 14:16

    I think yourchar *number[3]; should be char number[3];, or at least you should allocate space for each of the 3 number pointers.

    0 讨论(0)
  • 2021-01-27 14:33

    You haven't (at least, not in the pasted code) #included the header that defines the strtok function. In C, functions that haven't been prototyped yet are assumed to return int. Thus, we're assigning from an int (function result) to a char* (the type of token) without a cast.

    We don't want a cast, of course. We want to #include the header, so that the compiler understands what strtok returns.

    But we also don't really want to use strtok if there's anything else that will do the job. It has numerous limitations that aren't obvious. For robust string parsing, try sscanf.

    0 讨论(0)
提交回复
热议问题