0
What’s wrong with this code?
I made this simple code to test out functions but it shows no output. #include <iostream> using namespace std; void printName (string name [], int size) { for (int x = 0; x > size; x++) { cout << name [x] << endl; } } int main() { string myArr [] = {"David", "Ryan", "Bob"}; printName (myArr, 3); return 0; }
2 Respuestas
+ 1
your for loop:
for (int x = 0; x > size; x++) {
you need to change x > size to x < size because the way you have it the loop doesnt run. so it should be:
for (int x = 0; x < size; x++) {
0
Thanks I fixed it now!