-
Code:
cin >> binary[7];
//should be
cin >> binary;
edit: but with a buffer size of 8 you can only type a string 7 chars long. the 8th is reserved for null-termination character.
edit: another question. Have you covered any loop structures. do-while, while, or for?
-
I think the if/else if statement could work but would be an extremely round about way to get there, though. Probably what my instructor wants... But I'm still getting the same error message: Stack around the variable 'binary' was corrupted.
Is the for statement the only way to get around that?
-
The error message is because to are typing to much data for the array.
If you have
You are only able to use
binary[0]
binary[1]
binary[2]
binary[3]
binary[4]
binary[5]
binary[6] much be empty for the '\0' null-termination character.
This i believe is called a buffer over-run.
-
Oh, so that's what the book meant then. It works now that I extended the boundary of the char. Thanks so much Raigne. But I think I prefer your method. It's much neater. Now that means more time spend to finish the rest of my homework. But thanks again Raigne.
-
Anytime. Best of luck to you