| | |
Simple char array question
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I am making a tic tac toe game, and for the grid, I had originally made 9 variables to represent the grid's spaces, but instead, I would now like to use a single char array. I can make the array and print certain parts, but I can't change them.
For example:
But then if i want to change the first entry to also be a "o", how would I do that? I tried
But it didn't work, it said invalid conversion from char to const char (possibly the other way around...)
Thanks everyone.
For example:
char grid[] = "xoxoxoxox";But then if i want to change the first entry to also be a "o", how would I do that? I tried
grid[0] = "o";But it didn't work, it said invalid conversion from char to const char (possibly the other way around...)
Thanks everyone.
Two people already have -- Wolfie directly answering your question, SOS explaining something you need to understand. And here's a third:
TTT is played on a 3x3 grid, therefore you should consider using a 3x3 array (matrix), like
TTT is played on a 3x3 grid, therefore you should consider using a 3x3 array (matrix), like
char grid[3][3] The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- simple solution? Parsing question (C++)
- array question (C++)
- adding data into an char array (C++)
- two-dimensional char array (Java)
Other Threads in the C Forum
- Previous Thread: linked list problem!!!
- Next Thread: Inputting text (name) as opposed to an int (ID) - C programming
| Thread Tools | Search this Thread |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators initialization iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list lists locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql odf open opensource openwebfoundation owf pattern pdf performance pointer pointers posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling scripting segmentationfault send shape socketprograming socketprogramming stack standard string suggestions systemcall test testautomation unix urboc user voidmain() wab win32api windows.h






