C++ Compile error - LNK1120 unresolved externals

The following is an example I copied verbatim from the Internet, just to mak sure I wasn't doing anything wrong.  But, I'm getting error LNK 2019: unresolved external symbol
LNK 1120: 1 unresolved externals

and two warnings about how strtok is unsafe.


/* strtok example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] ="- This, a sample string.";
  char * pch;
  printf ("Splitting string \"%s\" into tokens:\n",str);
  pch = strtok (str," ,.-");
  while (pch != NULL)
  {
    printf ("%s\n",pch);
    pch = strtok (NULL, " ,.-");
  }
  return 0;
}
--TripWire--Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
phoffricConnect With a Mentor Commented:
It also builds fine using Cygwin. And it runs with these results:
$ ./a
Splitting string "- This, a sample string." into tokens:
This
a
sample
string
0
 
evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
Does it say what symbol? I can't see any problem and it builds just fine for me on VS2008.
0
 
AriMcConnect With a Mentor Commented:
It also compiles fine on VS2010.

0
 
--TripWire--Author Commented:
Ok weird.  It works for me now too.  Maybe it was something in the syntax I typed.

I'll award points for helping.  However, first, can someone help me tokenize a text file please?
0
 
evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
>> However, first, can someone help me tokenize a text file please?
You need to asker that as a new question.
http://www.experts-exchange.com/help.jsp?hi=23

You can use the "Related Question" feature to do that if you so wish.
http://www.experts-exchange.com/help.jsp?hi=414
0
All Courses

From novice to tech pro — start learning today.