Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 743
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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