Solved

C++  Compile error - LNK1120 unresolved externals

Posted on 2011-02-15
5
712 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--
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

615 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