Error C2015 Too Many Characters In Constant
Contents |
longer :P) and I'm now learning to make classes, public/private, constructors/destructors, that kind of stuff. I use Visual C++ 2008 Express Edition.
Visual Studio Too Many Characters In Constant
I get an error on the following piece of code (nothing spectacular, error c2015 visual studio just to try some things out): 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "stdafx.h" /*is this needed? It doesn't work otherwise :( */ #include too many characters in character constant
Error C2001 Newline In Constant
age) //set the age { herAge = age; } void Cat::makeSound() //print 'Miauw!' { cout << 'Miauw!\n'; } int main() { Cat Frisky; //Frisky is a Cat Frisky.setAge(6); //Her age is 6 Frisky.makeSound(); //print Miauw! cout << 'Frisky is ' << Frisky.getAge() << ' years of age!\n'; //get the age Frisky.makeSound(); //print Miauw! return 0; } The error code I get is the following:
Too Many Characters In Character Constant C
1
2
3
blahblahblah/standard file.cpp(30) : error C2015: too many characters in constant blahblahblah/standard file.cpp(39) : error C2015: too many characters in constant blahblahblah/standard file.cpp(39) : error C2015: too many characters in constant I tried some things but I can't find the error, I hope one of you can help me, cause I wanna move on. I'm stuck here for some time now :P. -Delpee PS: is this in the right section? Last edited on Aug 26, 2009 at 1:51pm UTC Aug 26, 2009 at 1:55pm UTC Warnis (230) You're trying to print one character in the cout when you really want to print a string. Replace your ' with " in line 27 and 36 Last edited on Aug 26, 2009 at 1:56pm UTC Aug 26, 2009 at 1:59pm UTC Delpee (10) I'm so stupid! :O Well, thanks! :D So ' is for when you want to print one character, but you use " when you want to print multiple? Aug 26, 2009 at 2:50pm UTC helios (13227) Single quotes (a different way to call the apostrophe) are used to get the integer representation of a single character. For ex
Languages , Windows Desktop Development > Visual C++ Question 0 Sign in to vote #include
C2105
if (answer!='tomorrow'||'Tomorrow') cout<<"Sorry"; cout<<"¿cómo se dice agua"; cin>>answer; if (answer='water'||'Water') cout<<"Correct"; c++ string else if (answer!='water'||'Water') cout<<"Sorry"; cout<<"Do you want to play again?"; } while (repeat=='Yes'); return 0; } //I'm trying to create a program to help someone learn English but C++ keeps http://www.cplusplus.com/forum/beginner/13782/ giving me Error C2015 where I have the correct answers. Wednesday, July 31, 2013 9:28 PM Reply | Quote Answers 0 Sign in to vote Are you comparing int with string ? Second thing instead of = use == . third '' used for character and water etc is not a character. There are plenty of mistake look carefully what are you doing. Thanks Rupesh Shukla Edited by Pintu Shukla Wednesday, July 31, 2013 9:31 https://social.msdn.microsoft.com/Forums/vstudio/en-US/f9738008-6355-492f-94d3-08cceb9c2883/c-error-c2015-too-many-characters-in-constant?forum=vcgeneral PM Proposed as answer by Pintu Shukla Thursday, August 01, 2013 2:05 PM Marked as answer by Anna CcMicrosoft contingent staff Wednesday, August 07, 2013 9:30 AM Wednesday, July 31, 2013 9:30 PM Reply | Quote 0 Sign in to vote #include
1 of 1 New Topic/Question Reply 4 Replies - 905 Views - Last Post: 31 July 2013 - 04:16 PM Rate Topic: #1 gamesun http://www.dreamincode.net/forums/topic/326057-c-error-c2015-too-many-characters-in-constant/ New D.I.C Head Reputation: 0 Posts: 2 Joined: 31-July 13 C++ error C2015 "Too many characters in constant" Posted 31 July 2013 - 03:10 PM #include
error messages. Tweet Most popular tags programming languages visual c++ compile time error messages programming-languages visual-c compile-time-error-messages java mysql dbms runtime-error-messages Photoshop oracle netbeans nudge photoshop mosek rasterize subversion php sql vector data svn facebook tomcat latex apache visual sap phpmyadmin runtime error messages c type layer windows eclipse-svn-subversion-java photos pool paypal sqlserver driver commit rsa 2010 adobe-premiere-pro c# jquery javascript firebug lyx asp memory-leaks Error C2015: too many characters in constant 0 votes This error message appears in Visual C++ when more than 4 characters are assigned to a character variable. Ex: char a = 'abcde'; compile time error messages programming languages visual c++ requested 5 years ago by errorbase (170,010 points) 1 Solution 0 votes It is always better to prefer constants with only one character if you are dealing with character variables. char a = 'a'; If you want to use constants with more than characters, you would choose strings instead of character variables. string a = "abcde"; solved 5 years ago by errorbase (170,010 points) Related errors 0 votes 1 solution Error C2020: too many characters in constant requested 5 years ago by errorbase (170,010 points) compile time error messages programming languages visual c++ 0 votes 2 solutions Fatal Error C1509: compiler limit : too many exception handler states in function (function). simplify function requested 5 years ago by errorbase (170,010 points) compile time error messages programming languages visual c++ 0 votes 3 solutions Fatal Error C1312: Too many conditional branches in function. Simplify or refactor source code requested 5 years ago by errorbase (170,010 points) compile time error messages programming languages visual c++ 0 votes 3 solutions Error C2603: (function) : Too many block scope static objects with constructor/destructors in function requested 5 years ago by errorbase (170,010 points) compile time error messages programming languages visual c++ 0 votes 1 solution Error C2026: string too big, trailing characters truncated requested 5 years ago by errorbase (170,010 points) compile