Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

string in VC++

Posted on 2004-10-17
3
Medium Priority
?
328 Views
Last Modified: 2010-04-01
Hi experts,

   Does anyone know why I failed to do the following declaration in VC++ ? thanks !!!
  (while I got no error without "string mystring;" ) please help ! thanks !!!

 #include "string.h"
  string mystring ;
-------------------------------
ompiling resources...
Compiling...
StdAfx.cpp
Compiling...
Bullet.cpp
GameObject.cpp
Monster.cpp
MyMap.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(48) : error C2146: syntax error : missing ';' before identifier 'mystring'
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(48) : error C2501: 'string' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\MyMap\MyMap.cpp(48) : fatal error C1004: unexpected end of file found
Generating Code...
Error executing cl.exe.

MyMap.exe - 3 error(s), 0 warning(s)
0
Comment
Question by:meow00
[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
3 Comments
 
LVL 23

Accepted Solution

by:
brettmjohnson earned 1200 total points
ID: 12336010
string.h is the include file for ANSI-C string functions, not C++ string classes.

try #include <string>  instead.



0
 
LVL 1

Author Comment

by:meow00
ID: 12336017
Hi I got exactly the same errors by using "#include <string>" ... :-(
0
 
LVL 12

Expert Comment

by:OnegaZhang
ID: 12336148
#include <string>
std::string mystringvar;

or
#include <string>
using namespace std;
string mystringvar;
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

704 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