small problem
I just started C++, and i've asked help before on a different code. Thanks for the people who helped me.
most of the text is finnish.
But now i need help with this practice code:
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 42 43 44 45 46 47 48 49 50 51 52 53
|
// Loop1.cpp : Defines the entry point for the console application.
// Loop test 1
#include "stdafx.h"
#include <iostream>
#include "cstdlib"
#include "sstream"
#include "string"
using namespace std;
void GNumber(void)
{
int a, b, c;
a=0;
b=0;
c=0;
while (1)
do
{
cout<<endl<<"Arvaa luku!"<<"huom. 0-10000"<<endl;
cin>>a;
if (a==666)
{
cout<<endl<<"Hienoa! Arvasit oikein!"<<endl;
break;
}
else
{
cout<<endl<<"Wrong! yritä uudelleen."<<endl;
continue;
}
}
}
int main()
{
int x;
cout<<" initializing..."<<" Test loop 1 Loop1 V. 0.1 BETA"<<endl;
cout<<endl;
cout<<"Tervetuloa Loputtomaan Loppiin, joka on minun harjoittelu-ohjelma."<<endl;
cout<<"kun arvaat luvun oikein, pääset pois."<<endl;
GNumber();
cout<<endl;
cout<<"Paina Enteriä lopettaaksesi"<<endl;
cin>>x;
return 0;
//loppu!
}
|
i get this error when compiling:
1 2 3 4 5 6
|
Compiling...
Loop1.cpp
c:\documents and settings\compaq_omistaja\omat tiedostot\visual studio 2008\projects\loop1\loop1\loop1.cpp(36) : error C2059: syntax error : '}'
Build log was saved at "file://c:\Documents and Settings\Compaq_Omistaja\Omat tiedostot\Visual Studio 2008\Projects\Loop1\Loop1\Debug\BuildLog.htm"
Loop1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
I tryed a few things myself, but they didn't help.
The problem is the while loop.
Syntax should be
1 2 3 4
|
do
{
//Code to be repeated here
} while (1);
|
Last edited on
Thank you really much =)
You saved my day!
Topic archived. No new replies allowed.