Click to See Complete Forum and Search --> : C++ Help
Shmoo
March 8th, 2002, 03:24 AM
Whats wrong with this code?
#include <stdlib.h>
#include <conio.h>
#include <iostream>
using namespace std;
*/
int main()
do
{
cout << "Still in the do...while loop" << endl;
} while (!kbhit());
return EXIT SUCCESS
}
The error message is:
Line 5: parse error before '/'
Any Suggestions?
oblio
March 8th, 2002, 03:41 AM
#include <stdlib.h>
#include <conio.h>
#include <iostream>
using namespace std;
int main(){
do
{
cout << "Still in the do...while loop" << endl;
} while (!kbhit());
return 0
}
AnthonyGayden
March 8th, 2002, 03:45 AM
Shmoo, I looked over the code for the hello world program you showed us in the irc. Here is what my version looks like.
#include <iostream.h>
int main()
{
cout << "Hello World!";
return(0);
}
shkuey
March 8th, 2002, 03:47 AM
You ended a comment without starting one, */ should be placed after a comment with /* before it.
Cheeseball
March 12th, 2002, 02:03 AM
You can technically use all the */'s you want in your code without an adverse effects...:) Just thought I would comment on that...:)
freeOn
March 12th, 2002, 03:11 AM
#include <stdlib.h>
#include <conio.h>
#include <iostream>
using namespace std;
*/
int main()
do
{
cout << "Still in the do...while loop" << endl;
} while (!kbhit());
return EXIT SUCCESS
}
Well Shmoo I get 7 errors with this code, so obivious stuff your doing wrong
1) <iostream> should be <iostream.h>
2) */ needs a closing comment */
3) your do statement is all messed up
4) wtf is (!kbhit()); I've never seen that in my life
5)if your going to use <conio.h> make sure you use getch(); to or else you defeat it's purpose
6)Learn how to do a while loop and execute conditions
here is an example, this program doesn't need that shit use void main () and get rid of it
If you need more help let me know
#include <iostream.h>
void main()
{
int x = 1;
while( x = 1)// put your loop condition in here
{
cout << "Still in the do...while loop";
}
}
Yes this is a never ending loop..
ihsir
March 12th, 2002, 03:53 AM
remove all .h in header files and remove the */
about the */ why have you used it ??
freeon:
kbhit() is a function that allows a process to happen while the user presses a key
it's in conio.h so he's right
freeOn
March 12th, 2002, 03:58 AM
I never heard that shit before, but it's good to know
gaxprels
March 12th, 2002, 04:46 AM
<iostream> should be <iostream.h> isn't exactly correct. <iostream.h> is deprecated in favor of using namespaces. instead of doing:
using namespace std...
why don't you just do
using std::cout;
using std::cin;
using std::endl;
In other words, only call the objects from the namespace you absolutely need. The whole
reason <iostream.h> is deprecated is so you can use the namespace in this manner. Any
decent optimizing compiler should strip out unneeded objects anyway, but this enforces that
for any compiler that doesn't. Just thought I would mention this.
Happy Hacking
Casablanca
March 18th, 2002, 06:25 PM
I have noticed that there is a curly bracket missing between the int main() and do...
you actually have it as
#include ..... blah blah
int main()
do
{
....
}
}
it should be
...
int main()
{
do
{
...
}
}
the indents are not necesary, but it makes it clearer to me for reading. I don't know about the kbhit() function... I have never seen it b4 either... but that does not mean it does not exist