View Single Post
Join Date: Jul 2008
Posts: 14
Reputation: mike_g is an unknown quantity at this point 
Solved Threads: 3
mike_g mike_g is offline Offline
Newbie Poster

Re: Making War card game

 
0
  #8
Aug 22nd, 2008
>>You should be able to store the data for each card within an integer. You could >>then get the suit as card / 10 and you could get the rank as card % 10. I find this approach >>simplifies things a little.

Not getting this fully. The suit and the rank is where you lost me
Something like:
  1. int card = 39;
  2. char suit = (card / 10)+'A';
  3. int rank = (card % 10)+1;
  4. printf("suit: %c, rank: %d", suit, rank);

]I used fseek, fopen, fclose, etc but I seem to always do a pointer/memory violation as a popup window the red X pops up always when it gets to saving/opening. Some tips or pages with examples would be nice
IMO the easiest way to do this would be to load the entire file to ram, then overwrite the file when youre done. You could use fscanf to load the file content, and fprintf to print the output. Google should give you pleny examples of their usage.
Reply With Quote