program problem

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jan 2008
Posts: 7
Reputation: sir avalanche is an unknown quantity at this point 
Solved Threads: 0
sir avalanche sir avalanche is offline Offline
Newbie Poster

program problem

 
0
  #1
Jan 30th, 2008
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:
  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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,996
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 308
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: program problem

 
0
  #2
Jan 30th, 2008
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
Niek
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 7
Reputation: sir avalanche is an unknown quantity at this point 
Solved Threads: 0
sir avalanche sir avalanche is offline Offline
Newbie Poster

Re: program problem

 
0
  #3
Jan 30th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: program problem

 
0
  #4
Jan 30th, 2008
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.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,996
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 308
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: program problem

 
0
  #5
Jan 30th, 2008
Originally Posted by hollystyles View Post
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++

Originally Posted by hollystyles View Post
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]
Niek
Last edited by niek_e; Jan 30th, 2008 at 5:19 am.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 7
Reputation: sir avalanche is an unknown quantity at this point 
Solved Threads: 0
sir avalanche sir avalanche is offline Offline
Newbie Poster

Re: program problem

 
0
  #6
Jan 30th, 2008
Originally Posted by hollystyles View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 7
Reputation: sir avalanche is an unknown quantity at this point 
Solved Threads: 0
sir avalanche sir avalanche is offline Offline
Newbie Poster

Re: program problem

 
0
  #7
Jan 30th, 2008
Originally Posted by niek_e View Post
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?
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: program problem

 
0
  #8
Jan 30th, 2008
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
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 833 | Replies: 7
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC