0
#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?

4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by jbennet
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."

Edited by jonsca: n/a

0

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

Edited by restrictment: n/a

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.