cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Beginners : Do While Loop problem
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

post  Do While Loop problem

HeatMan (65)
When I tried compile the Do-While Loop tutorial program, the compiler (CodeBlocks) writted:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

using namespace std;

int main()
{
    unsigned long n;
    do
    {
        cout << "Enter a number (0 to end): ";
        cin >> n;
        cout << "You entered" << n << "!"'/n';
    }
    while (n != 0);
    cin.get();
}


C:\Codes\C++\C++ Projects\DoWhile.c|12|warning: multi-character character constant|
C:\Codes\C++\C++ Projects\DoWhile.c||In function `int main()':|
C:\Codes\C++\C++ Projects\DoWhile.c|12|error: expected `;' before '\x2f6e'|
C:\Codes\C++\C++ Projects\DoWhile.c|15|error: statement cannot resolve address of overloaded function|
||=== Build finished: 2 errors, 1 warnings ===|

Why?

Edit: Noticed one error >.>" But the other...
| Last edited on
firedraco (657)
cout << "You entered" << n << "!"'/n';

You are probably trying to do this:

cout << "You entered" << n << "!\n";

There is no need to surround them with '', just put it directly into the string. Also, your escape \ was the incorrect one.
| Last edited on
HeatMan (65)
Ok :) Thanks!
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us