Jump to content
  • Advertisement
Sign in to follow this  
dolphins87

Visual C++ 2008 Complier Problems With Strings

This topic is 3258 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

when I go to complie simple code from a book im using I get these error messages. 1>.\main.cpp(4) : error C2065: 'string' : undeclared identifier 1>.\main.cpp(4) : error C2146: syntax error : missing ')' before identifier 'first' 1>.\main.cpp(4) : error C2182: 'printName' : illegal use of type 'void' 1>.\main.cpp(4) : error C2059: syntax error : ')' 1>.\main.cpp(7) : error C2064: term does not evaluate to a function taking 2 arguments 1>.\main.cpp(10) : error C2065: 'string' : undeclared identifier 1>.\main.cpp(10) : error C2146: syntax error : missing ')' before identifier 'first' 1>.\main.cpp(10) : error C2182: 'printName' : illegal use of type 'void' 1>.\main.cpp(10) : error C2374: 'printName' : redefinition; multiple initialization 1> .\main.cpp(4) : see declaration of 'printName' 1>.\main.cpp(10) : error C2059: syntax error : ')' 1>.\main.cpp(11) : error C2143: syntax error : missing ';' before '{' 1>.\main.cpp(11) : error C2447: '{' : missing function header (old-style formal list?) 1>Build log was saved at "file://c:\Users\dolphinsa87\Desktop\Book 1 Chp 4\4.9\Debug\BuildLog.htm" 1>4.9 - 12 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== but I have checked my folders and the string.h is there. I don't know if I jus have my compler setup correctly but I can seem to find the anwsers anywhere. Here is the code if u need that to.
#include<iostream>
#include<stdlib.h>
#include<string>
void printName(string first, string second);
int main()
{
	printName("Thomas","Jefferson");
	return 0;
}
void printName(string first, string second)
{
	string fullName = first + " " + second;
	std::cout << fullname << std::endl;
}

Share this post


Link to post
Share on other sites
Advertisement
There are three ways you can solve your problem :

- you can place a : using namespace std; right after the include region which is frowned upon because you do not need all the definitions in the std namespace

- you can place a : using std :: string; right after the include region

- you can put std :: in front of every string declaration

Also : instead of std::cout << fullname << std::endl;
std::cout << fullName << std::endl;

Share this post


Link to post
Share on other sites
thanks that worked I us thought that string were included in that namespace so all I reasearched was the complier issues.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!