+ 5
Problem with cout char array
char words[5][20] = {"ball", "earth", "government", "environment", "someone"}; cout << words[3]; when using g++ on PC it prints: environment @ @ shouldn't appear at all, all other words print fine, index 3 is problem no matter the word. Google didn't help
11 Respuestas
+ 6
+ 5
I also tried debugging, when index is 3, in gdb I don't see @, but cout magicaly prints it... also via gdb I printed all possible addresses and values, all good... I'll try tomorrow again to see what exactly is messing up my output
+ 4
logic is correct from what is tested, only problem is 3rd index of array, no matter what's the word inside it, so it can't be logic problem
+ 4
I'm using char arrs simply to understand pointers and how they work in memory I'll move to strings later... maybe you're right I'll check that piece of code out (and I understand exactly what you wrote) but it works flawlessly when rand()%5 is not 3.... anyways thank you so much 😀
+ 4
hey guys/girls, I made slight modification (Martin Taylor's advice that something is wrong with pointers so I got rid of them) and now you can see problem even on SoloLearn's Compiler, just input single char... could it be string terminator?
+ 3
sorry, it's on my native lang, it's hangman, just input chars, you'll get it 😀
https://code.sololearn.com/cfl1k1RObw2e/?ref=app
+ 1
good luck with that :)
0
Hi, can you share your code pls ?