Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 731
  • Last Modified:

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;
}
0
--TripWire--
Asked:
--TripWire--
4 Solutions
 
evilrixSenior 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
 
AriMcCommented:
It also compiles fine on VS2010.

0
 
phoffricCommented:
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
 
--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
 
evilrixSenior 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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now