Windows says it didnt work but it did.

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

Join Date: Jan 2008
Posts: 41
Reputation: rysin is an unknown quantity at this point 
Solved Threads: 0
rysin's Avatar
rysin rysin is offline Offline
Light Poster

Windows says it didnt work but it did.

 
0
  #1
Nov 8th, 2009
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9.  
  10. string names[] = {"Jim", "Rob", "Sam", "Tim"};
  11.  
  12. int i;
  13. i = 0;
  14. string stain;
  15. stain = "f";
  16. while (stain == "f") {
  17. if (names[i] == "") {
  18. stain = "p";
  19. }
  20. i += 1;
  21. }
  22. for (int go = 0; go <= i; go += 1) {
  23. cout << names[go] << endl;
  24. }
  25. int stop;
  26. cin >> stop;
  27.  
  28. }

I wrote this code to practice arrays and I just want it to loop through and print out the names. It prints out each name on new lines like its supposed to but then Windows says "names.exe has encountered a problem and needs to close. We are sorry for the inconvenience." Then it gives you the option to send an error report or dont send. How do I get that to go away?
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 629
Reputation: jonsca will become famous soon enough jonsca will become famous soon enough 
Solved Threads: 85
Sponsor
jonsca jonsca is offline Offline
Practically a Master Poster
 
0
  #2
Nov 8th, 2009
Then it gives you the option to send an error report or dont send. How do I get that to go away?
Write a program that doesn't overstep your name array and crash. Only giving you a hard time...

There isn't a next element to test after "Tim."
Last edited by jonsca; Nov 8th, 2009 at 4:30 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 140
Reputation: restrictment is on a distinguished road 
Solved Threads: 10
restrictment's Avatar
restrictment restrictment is offline Offline
Junior Poster
 
0
  #3
Nov 8th, 2009
Edit: Nvm, I think I know what you are trying to do, and that wouldn't work..
Last edited by restrictment; Nov 8th, 2009 at 5:21 pm.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 41
Reputation: rysin is an unknown quantity at this point 
Solved Threads: 0
rysin's Avatar
rysin rysin is offline Offline
Light Poster
 
0
  #4
Nov 9th, 2009
Ahh alright thanks anyway, ill keep working with it when I get rid of some spanish work.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,273
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 544
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator
 
-7
  #5
Nov 9th, 2009
secondly, your main() must return 0
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the C++ Forum


Views: 243 | Replies: 4
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC