943,546 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 1005
  • C++ RSS
Jan 30th, 2008
0

program problem

Expand Post »
ok. so i decided to make a very irritating program that fills the computer its run on with junk. here is what i have done yet:
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <fstream>
  3. int main () {
  4. int i;
  5. ofstream filut1 ("allisdust1.txt");
  6. ofstream filut2 ("allisdust2.txt");
  7. ofstream filut3 ("allisdust3.txt");
  8. ofstream filut4 ("allisdust4.txt");
  9. ofstream filut5 ("allisdust11.txt");
  10. ofstream filut6 ("allisdust5.txt");
  11. ofstream filut7 ("allisdust6.txt");
  12. ofstream filut8 ("allisdust7.txt");
  13. ofstream filut9 ("allisdust8.txt");
  14. ofstream filut10 ("allisdus9.txt");
  15. ofstream filut11("allisdust10.txt");
  16. start:;
  17. int blessing;
  18. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  19. for (i=100;1>0;i--) {
  20. filut1<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  21. }
  22. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  23. for (i=100;1>0;i--) {
  24. filut2<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  25. }
  26. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  27. for (i=100;1>0;i--) {
  28. filut3<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  29. }
  30. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  31. for (i=100;1>0;i--) {
  32. filut4<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  33. }
  34. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  35. for (i=100;1>0;i--) {
  36. filut5<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  37. }
  38. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  39. for (i=100;1>0;i--) {
  40. filut6<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  41. }
  42. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  43. for (i=100;1>0;i--) {
  44. filut7<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  45. }
  46. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  47. for (i=100;1>0;i--) {
  48. filut8<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  49. }
  50. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  51. for (i=100;1>0;i--) {
  52. filut9<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  53. }
  54. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  55. for (i=100;1>0;i--) {
  56. filut10<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  57. }
  58. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  59. for (i=100;1>0;i--) {
  60. filut11<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  61. }
  62. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  63. for (i = 100;i>0;i--) {
  64. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  65. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  66. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  67. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  68. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  69. cout<< "HAIL TZEENTCH AND HIS SERVANT, SIR AVALANCHE!"<< endl;
  70. }
  71. for (i =100; i>0; i--) {
  72. cout<< "BLESS THE CHANGER OF WAYS AND HIS SERVANT, SIR AVALANCHE: PRESS ONE!"<< endl;
  73. cin>> blessing;
  74. if (blessing !== 1) {
  75. cout<< "INFIDEL! TIME TO START ALL OVER AGAIN!"<< endl;
  76. goto start;
  77. }
  78. }
  79. }
so, i get THESE build errors:
spammer2.cpp: In function `int main()':
spammer2.cpp:5: error: `ofstream' undeclared (first use this function)
spammer2.cpp:5: error: (Each undeclared identifier is reported only once for each function it appears in.)
spammer2.cpp:5: error: expected `;' before "filut1"
spammer2.cpp:6: error: expected `;' before "filut2"
spammer2.cpp:7: error: expected `;' before "filut3"
spammer2.cpp:8: error: expected `;' before "filut4"
spammer2.cpp:9: error: expected `;' before "filut5"
spammer2.cpp:10: error: expected `;' before "filut6"
spammer2.cpp:11: error: expected `;' before "filut7"
spammer2.cpp:12: error: expected `;' before "filut8"
spammer2.cpp:13: error: expected `;' before "filut9"
spammer2.cpp:14: error: expected `;' before "filut10"
spammer2.cpp:15: error: expected `;' before "filut11"
spammer2.cpp:18: error: `cout' undeclared (first use this function)
spammer2.cpp:18: error: `endl' undeclared (first use this function)
spammer2.cpp:20: error: `filut1' undeclared (first use this function)
spammer2.cpp:24: error: `filut2' undeclared (first use this function)
spammer2.cpp:28: error: `filut3' undeclared (first use this function)
spammer2.cpp:32: error: `filut4' undeclared (first use this function)
spammer2.cpp:36: error: `filut5' undeclared (first use this function)
spammer2.cpp:40: error: `filut6' undeclared (first use this function)
spammer2.cpp:44: error: `filut7' undeclared (first use this function)
spammer2.cpp:48: error: `filut8' undeclared (first use this function)
spammer2.cpp:52: error: `filut9' undeclared (first use this function)
spammer2.cpp:56: error: `filut10' undeclared (first use this function)
spammer2.cpp:60: error: `filut11' undeclared (first use this function)
spammer2.cpp:73: error: `cin' undeclared (first use this function)
spammer2.cpp:74: error: expected primary-expression before '=' token
spammer2.cpp:79:2: warning: no newline at end of file
Process terminated with status 1 (0 minutes, 0 seconds)
28 errors, 1 warnings
_______________________________________

what is wrong? and, please tell me what command to use to run another program.
and don't just say "why do you want to do this?"
thanks. out.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sir avalanche is offline Offline
7 posts
since Jan 2008
Jan 30th, 2008
0

Re: program problem

I COULD help you, because the errors are all related to the same problem, but without asking "why do you want to do this?" I can't be sure that you're not trying to make somesort of 'virus'.
So I won't help, sorry
Last edited by Nick Evan; Jan 23rd, 2011 at 4:10 pm.
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Jan 30th, 2008
0

Re: program problem

ok. this isnt a virus, just that a friend said that i couldn't make a program, so i9'm going to show him i can program. and this isnt very harmful, only creates ten files wich honour me. why i said that you shouldnt ask why was that i need the answer, not another question
Last edited by sir avalanche; Jan 30th, 2008 at 4:52 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sir avalanche is offline Offline
7 posts
since Jan 2008
Jan 30th, 2008
0

Re: program problem

So far your friend is right then!

Ooh that's so cruel.

What is 'start:' I'm no c/c++ expert but that doesn't look like valid syntax to me.

Also you need to prefix cout with std:: or put a using namespace std; at the top between your include directives and the main function. Main should really be int main(int argc, char *argv[])

You seem to have one too many closing braces on the last line.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Jan 30th, 2008
0

Re: program problem

So far your friend is right then!
What is 'start:' I'm no c/c++ expert but that doesn't look like valid syntax to me.
Actually: it is (sort of). It's a label where you point a 'goto' to. It's a horrible way to loop and should be avoided at all times. So the fact that you didn't know it means that you had a good teacher for C++

Also you need to prefix cout with std:: or put a using namespace std; at the top between your include directives and the main function. Main should really be int main(int argc, char *argv[])

You seem to have one too many closing braces on the last line.
Agreed on the namespace part (fstream requires it too).
Main can also be declared as int main() , it's also standard.
The brackets look ok to me, but due to avalanche's sloppy indention, I can't be sure
[edit] On second look, you might be right [/edit]
Last edited by Nick Evan; Jan 23rd, 2011 at 4:10 pm.
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Jan 30th, 2008
0

Re: program problem

So far your friend is right then!

Ooh that's so cruel.

What is 'start:' I'm no c/c++ expert but that doesn't look like valid syntax to me.

Also you need to prefix cout with std:: or put a using namespace std; at the top between your include directives and the main function. Main should really be int main(int argc, char *argv[])

You seem to have one too many closing braces on the last line.
start is a etiquette for the goto command. and when i do a second check on this program i can too see most of those faults.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sir avalanche is offline Offline
7 posts
since Jan 2008
Jan 30th, 2008
0

Re: program problem

Quote ...
Actually: it is (sort of). It's a label where you point a 'goto' to. It's a horrible way to loop and should be avoided at all times. So the fact that you didn't know it means that you had a good teacher for C++
Niek
i know its a bad way to loop it, but here it WAS in a if statement, which makes it more forgivable?
Last edited by Nick Evan; Jan 23rd, 2011 at 4:10 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sir avalanche is offline Offline
7 posts
since Jan 2008
Jan 30th, 2008
0

Re: program problem

Quote ...
So the fact that you didn't know it means that you had a good teacher for C++
He he, I didn't have a C++ teacher! I do know what labels are but I don't think I've used one for years let alone used one in C++ which is why I was stumped. I should have STFW
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: problem with win32 GUI.....please help me
Next Thread in C++ Forum Timeline: graphics.h problem in VS.NET 2003 IDE





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC