944,030 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 436
  • C++ RSS
Nov 8th, 2009
0

Windows says it didnt work but it did.

Expand Post »
C++ Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
rysin is offline Offline
41 posts
since Jan 2008
Nov 8th, 2009
0
Re: Windows says it didnt work but it did.
Quote ...
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.
Sponsor
Featured Poster
Reputation Points: 1165
Solved Threads: 578
Quantitative Phrenologist
jonsca is offline Offline
4,271 posts
since Sep 2009
Nov 8th, 2009
0
Re: Windows says it didnt work but it did.
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.
Reputation Points: 102
Solved Threads: 17
Posting Whiz in Training
restrictment is offline Offline
228 posts
since Oct 2009
Nov 9th, 2009
0
Re: Windows says it didnt work but it did.
Ahh alright thanks anyway, ill keep working with it when I get rid of some spanish work.
Reputation Points: 10
Solved Threads: 0
Light Poster
rysin is offline Offline
41 posts
since Jan 2008
Nov 9th, 2009
-7
Re: Windows says it didnt work but it did.
secondly, your main() must return 0
Moderator
Featured Poster
Reputation Points: 1800
Solved Threads: 575
Moderator
jbennet is offline Offline
16,525 posts
since Apr 2005

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: Cross Class Function Calling
Next Thread in C++ Forum Timeline: Issues with declaring vector iterator





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


Follow us on Twitter


© 2011 DaniWeb® LLC