Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 08-14-2009, 06:48 PM   #1
In Runtime
 
TitanMATRIX's Avatar
 
Join Date: Jul 2009
Posts: 202
Send a message via MSN to TitanMATRIX
Default C++ 'Too many characters in constant'

I dont understand this. I have C++ 2008 Express edition and I keep running into this compilier error of 'Too many characters in constant.'

I tried to do even the simplest "helloworld" program and it still doesn't work. I am on another computer and it works but for some reason its not wanting to work on my laptop but here is what I'm working with...


#include "stdafx.h"

#include <iostream>

int main ()

{
using namespace std;
cout << 'Hello World' << endl;
return 0;
}

This is so easy yet for some reason it won't compile... am I not seeing something here?
__________________

__________________
***Network Warrior***
TitanMATRIX is offline   Reply With Quote
Old 08-14-2009, 07:00 PM   #2
j03
~~~~~~~~
 
Join Date: Jan 2005
Location: Wales
Posts: 5,556
Send a message via MSN to j03
Default Re: C++ 'Too many characters in constant'

You need to use double (") and not single (') quotes around the text.
__________________

j03 is offline   Reply With Quote
Old 08-14-2009, 07:00 PM   #3
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: C++ 'Too many characters in constant'

You're putting single quotes round a string, which the compiler is most likely trying to interpret as a single character. Try replacing them with double quotes

EDIT: Damn, beaten to it, just!
berry120 is offline   Reply With Quote
Old 08-14-2009, 07:08 PM   #4
j03
~~~~~~~~
 
Join Date: Jan 2005
Location: Wales
Posts: 5,556
Send a message via MSN to j03
Default Re: C++ 'Too many characters in constant'

Haha, That was pretty close
j03 is offline   Reply With Quote
Old 08-14-2009, 07:27 PM   #5
In Runtime
 
TitanMATRIX's Avatar
 
Join Date: Jul 2009
Posts: 202
Send a message via MSN to TitanMATRIX
Default Re: C++ 'Too many characters in constant'

Aha! Man I feel like an idiot...
__________________
***Network Warrior***
TitanMATRIX is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 07:17 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0