Hello all, I am new to this board, as well as fairly new to C++. The past year I have taken a class at my high school in C++ which is ending in a final project. I choose a simple memory game(as in, the user picks a "card" from a board, it flips over, user picks another "card" it flips over, the user tries to match the cards). I have a 2d array that represents the board, and is randomly filled with the numbers 97-112(ascii values of a-p which correspond to separate .jpg picture files). I use a waitmouseclick statement to find the spot on the board where the user clicked, then compare the coordinates to the board array to figure out which picture to display. I use a strcat statement to add a ".jpg" to the end of the letter so that it will be in the proper format for outputting...
pic = board;
picname = char(pic);
image testImage(picname, JPEG);
"pic" is an integer that represents the randomly generated value in the "board" array. "picname" is the char variable that initially holds the char value of "pic", then gets a ".jpg" added to the end by the strcat. I then pull the image and display it.
My problem is that this whole part that gets a card is a separate function, which can be called anytime I need the user to click a card. Therefore, every time the function is called, another ".jpg" is added to the end of the "picname" variable, and after the first time through, no picture is outputted and the program ends. It will wait for the user to click, display the right picture, but when the next picture should be displayed the program ends. My question is this: How can I reset the variable(in this case I declare it as "char picname" each time the function is run... or... is there a way to designate where the strcat statement begins adding the ".jpg"?
Thank you for your time/help
edit: Sorry, I forgot to mention that I am using codewarrior with the CMU graphics package. My teacher told me to make sure I include this information when posting.