Solved

C++  Compile error - LNK1120 unresolved externals

Posted on 2011-02-15
5
699 Views
Last Modified: 2012-05-11
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
Comment
Question by:--TripWire--
5 Comments
 
LVL 40

Assisted Solution

by:evilrix
evilrix earned 62 total points
ID: 34901727
Does it say what symbol? I can't see any problem and it builds just fine for me on VS2008.
0
 
LVL 9

Assisted Solution

by:AriMc
AriMc earned 32 total points
ID: 34901799
It also compiles fine on VS2010.

0
 
LVL 32

Accepted Solution

by:
phoffric earned 31 total points
ID: 34901818
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
 

Author Comment

by:--TripWire--
ID: 34901873
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
 
LVL 40

Assisted Solution

by:evilrix
evilrix earned 62 total points
ID: 34901898
>> 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now