Skip to content
Advertisement

Tag: scanf

Why does running C code in Vim skip scanf()?

I’m using neovim in arch linux with the gcc C compiler, this is what I use in my .vimrc to compile and run map <F5> :w <CR> :!gcc % -o %< && ./%< <CR> The issue is that my code will run fine but any scanf() functions won’t prompt an input and will be ignored as the program will runs.

Variable reset after scanf

I wrote the below function : I print the currentPlayer on any level to see what’s going on -> here what I get: Why the current player is 0 after scanf? I didn’t touch it. Answer The buffer location has only room for 2 characters and scanf puts an extra NUL character at end. Therefore you have a stack corruption

Advertisement