So I have this code:
#include <iostream>
#include <string.h>
using namespace std;
struct helloworld {
char name[1];
};
main() {
struct helloworld test[2];
strcpy(test[0].name, "No .1");
strcpy(test[1].name, "No .2");
for (int integer = 0; integer < 2; integer++) {
cout << test[integer].name << endl;
}
}
and I save it to a file called test.cpp. To compile the file, I do
g++ -o main test.cpp
Then when I run ./main this is the output I get
NNo .2
No .2
This is the expected output
No .1
No .2
Any ideas of why I am getting this error how to fix this bug?