Thread: strtok Error

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    21

    strtok Error

    I am compiling with the -ansi flag, i get the following errors:

    Code:
    p1.c: In function ‘main’:
    p1.c:76: warning: assignment makes pointer from integer without a cast
    p1.c:79: warning: assignment makes pointer from integer without a cast
    p1.c:80: warning: passing argument 1 of ‘atoi’ makes pointer from integer without a cast
    /usr/include/stdlib.h:148: note: expected ‘const char *’ but argument is of type ‘int’
    p1.c:81: warning: passing argument 1 of ‘atoi’ makes pointer from integer without a cast
    /usr/include/stdlib.h:148: note: expected ‘const char *’ but argument is of type ‘int’
    pg1.c:89: warning: assignment makes pointer from integer without a cast
    I am using the strtok_r function, but it keeps on throwing these errors at me.

    Any suggestions what i am doing wrong?

    Thanks

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    You really need to show the code you're using.

    But strtok_r() is not standard, so the -ansi flag will kill it off. You can ask for a POSIX environment by defining the macro _XOPEN_SOURCE to be 500 (or some suitable value; search for _XOPEN_SOURCE to learn about it). Or don't use -ansi.

    Also, build with the -Wall flag. Always. That will enable warnings that should help you track these problems down.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Looks a lot like you've got ' ' quotes around some strings, rather than " "
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM