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

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."

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

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

secondly, your main() must return 0

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.