954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Windows says it didnt work but it did.

#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main() {


string names[] = {"Jim", "Rob", "Sam", "Tim"};

int i;
i = 0;
string stain;
stain = "f";
while (stain == "f") {
    if (names[i] == "") {
        stain = "p";
        }
    i += 1;
    }
for (int go = 0; go <= i; go += 1) {
    cout << names[go] << endl;
    }
int stop;
cin >> stop;

}


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?

rysin
Light Poster
41 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 
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."

jonsca
Quantitative Phrenologist
Team Colleague
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
 

Edit: Nvm, I think I know what you are trying to do, and that wouldn't work..

restrictment
Posting Whiz in Training
228 posts since Oct 2009
Reputation Points: 102
Solved Threads: 17
 

Ahh alright thanks anyway, ill keep working with it when I get rid of some spanish work.

rysin
Light Poster
41 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

secondly, your main() must return 0

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You