Array with chars in c -


I'm new to everyone and just want to try some programming for fun! My first idea was to make a tick-tank-toe game. In the following code I am trying to generate a field. It works to some degree, but when I test it, it clears entries fail [1] [0] and fails [2] [0] Besides, I do not understand anything, if I save more of a letter in an entry, for example XX, it is moving in some other place, I'm guessing that C. There is a problem with saved space work, happy for any response!

  #include & lt; Stdio.h & gt; Main () {int i, j; Four folds [3] [3]; For (J = 0; J & lt; 3; J ++) {for (i = 0; i  

From this line:

  scanf ("% S", and fail [i] [ja]);  

You are reading a string (multiple characters) and keeping them where there should be only one letter, it will damage the adjacent letters which are stored nearby. Use something like:

  scanf ("% c", and fail [i] [j]);  

Reading a letter around each time. But this solution is not perfect, because now if you feed a lot of character, unless you try to read them again, they will remain stored, which is the result of some strange behaviors, such as your input Printing several times without waiting:

  2. Column 1. Row: 3. Column 1. Row: 1. Column 2. Line:  

The correct answer depends on whether you feed multiple inputs at once.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -