-
March 8th, 2002, 03:24 AM
#1
Member
C++ Help
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?
-
March 8th, 2002, 03:41 AM
#2
#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
}
-
March 8th, 2002, 03:45 AM
#3
Member
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);
}
-
March 8th, 2002, 03:47 AM
#4
You ended a comment without starting one, */ should be placed after a comment with /* before it.
-Shkuey
Living life one line of error free code at a time.
-
March 12th, 2002, 02:03 AM
#5
You can technically use all the */'s you want in your code without an adverse effects... Just thought I would comment on that...
-
March 12th, 2002, 03:11 AM
#6
#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 **** 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..
-
March 12th, 2002, 03:53 AM
#7
Member
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
-
March 12th, 2002, 03:58 AM
#8
I never heard that **** before, but it's good to know
-
March 12th, 2002, 04:46 AM
#9
Senior Member
<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
-----------------------------------------------------
Warfare is the Way of deception.
-Sun Tzu \"The Art of War\"
-
March 18th, 2002, 06:25 PM
#10
Junior Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|