WOW thank you so much :) I totally wasn't thinking about that null terminator lol.
Type: Posts; User: crazygopedder
WOW thank you so much :) I totally wasn't thinking about that null terminator lol.
Or maybe not...man I hate bugs like this. I've been through the program line by line, function by function, been through the whole algorithm...still can't figure out what's going wrong.
Maybe something was funky with the .txt file I was giving it. I made a new .txt file with just two words and now it works perfect.
Hmm I should've seen that. The game still acts funny though. I changed the functions around a bit, but to no avail. For some reason the blank word string and the real word string aren't the same...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define MAXSIZE 30
#define MAXWORDS 1000
#define MAXINCORRECT 5
char getGuess(int usedletters[26]);
I made a basic hangman game that reads in a text file with words, selects a random word, prints out the letters from the random word represented as underscores, asks the user what letter they guess,...
I am forever indebted to you guys. Thanks for all your help. My program is now complete. I changed domove to this:
int doMove(int puzzle[][PUZZLE_SIDE], int move)
{
int j = 0;
...
Yea I know gets would be better but for this assignment it's not necessary. I'm still confused though. I know I need to swap the elements of the array, but like I said earlier we can't change the...
Here let me post the whole program. You guys are really helpful and I know I'm getting close to making this work, I appreciate it.
#include <stdio.h>
#include <time.h>
#define...
The for loops will find the number the user wants to move. It's understood in the assignment that they enter a number that's actually in the puzzle. Just for kicks though I ran the program and...
Yea exactly. How would I go about doing that though? The program is an assignment for class and we're not allowed to change the function prototypes.
Ok, my puzzle program is almost complete. I just can't figure out how to swap the number the user chooses to put in the blank space, and the blank space.
Here's the function that sees if the move...
Too quick to celebrate lol...I need a little bit of help. The program loads random puzzles...sort of. If I run the program it loads/displays the 1st puzzle, then the 2nd, then the 3rd, then random...
YES! I was just about to post my code again but I figured it out. I can now load/display random puzzles at will :) Muahahahaha. Still a long way to go on this prog but glad to be done with those...
I see what you mean there. I moved the read-number-of-puzzles code to main, before the while loop for the game. I changed int puzzle[200][PUZZLE_SIDE]; to int puzzle[i][j]; and made necessary...
Is it something to do with the blank line in between puzzles?
Ok, I arbitrarily declared puzzles as int puzzles[200][PUZZLE_SIDE]; but still the same problem, it only reads/prints the first puzzle. I can't make it read any other puzzle.
That's what I was thinking, but Dev-C++ won't let me code it as int puzzle[][PUZZLE_SIDE];
it says the array size is missing? I thought one could declare an array like this.
Here let me post the whole program. Maybe there's a problem somewhere else? NOTE the program is just a scaffold at this point.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
...
Anyone? I've searched the forums already and found a similar problem but not the same. This shouldn't be all too complicated, it's just a 2D array of ints.
Ok, I am making a puzzle game. For my function loadPuzzle, I want to read in a random puzzle to a 2d array. The .txt file looks like this:
3
1 0 2 3
5 6 7 4
9 10 11 8
13 14 15 12
15 1 2 3...
Thanks guys I figured it out now. Sometimes the simplest problems can be a real pain lol.
Well I forgot to close the files ;/ but that was never the problem anyway. *Sigh* I know what you mean about fputc for every char, I just can't figure out how to implement it.
It capitalizes every letter in the .txt file.
#include <stdio.h>
#include <ctype.h>
int main(void)
{
FILE* fin;
FILE* fout;
char inputfname[256];
char outputfname[256];
char currentchar;