Alright, its all working now, lots and lots of thanks to you, you've really been a great help :)
And thanks for taking the time to actually explain what i was doing wrong... Hopefully i've never...
Type: Posts; User: Newklear
Alright, its all working now, lots and lots of thanks to you, you've really been a great help :)
And thanks for taking the time to actually explain what i was doing wrong... Hopefully i've never...
Ahh okay, didnt know that was the return value of fscanf.
Alright, so the function showScoreboard works great now, but the sortScoreboard is still kind of messed up... I tried adding the same code...
I'm not able to test the code at the moment, but i was looking through it and am now wondering what that "num" variable is...
You can store both the player.name and player.points in the same "int...
Okay, have had alot to do so havent been able to program alot, but i tried it out again today, with no result... :(
I tried following your 1-7 steps, but failed obviously.
Heres the two...
Okay, so i've tried the fprintf and fscanf out a little and printing to the scoreboard textfile works, and reading from it works halfway... I can read the entries on the scoreboard, but it reads one...
Okay, so the function that adds entries to the scoreboard looks like this:
void addToScoreboard(int numberOfGuesses)
{
FILE *scoreboardFile = fopen("scoreboard.txt", "a");
char...
Hello,
I've been sort of making a tiny game to learn the basics in C programming where the computer generates an array of four unique, random numbers and then the player tries to guess those four...
Ahh, lots of thanks to both of you, it seems to be working now.
Gonna go over it a couple more times to see what it was i missed and try to learn from it now!
Ahh yes, sorry... But it should return R S S S , since the first 4 is correct and should give you an 'R', but the next three 4's are wrong, but still exist in the secretNumber array and should give...
I tried following that, and got this:
for(i=0; i<ARR_SIZE; i++)
{
if( guess[i] == secretNumber[i] )
{
help[i] = 'R';
}
Yes, i tried it... Did you? :P
Mine was nicely indented though, wasn't it? :)
No, that doesnt work either....
I tried the code you wrote and if the guess array and the secretNumber array were exactly the same, it produced S S S S, when it should produce R R R R, since all...
tried changing it to j<=i, but its still not right...
for example, if the secretNumber array is
6, 3, 9, 2
and the guess array is
1, 2, 3, 4,
it returns
_ _ S _
when it should return...
if by handling it you mean for example doing this instead:
char help[ARR_SIZE] = {'_','_','_','_'};
then no, it didnt help...
Yes, i've tried this, but its the number 2 in your approach that i'm having problems with... :S
Alright, sorry if it was confusing, the problem is that it doesnt give the correct hints. For example, it sometimes gives an '_' when you should get an 'S'...
I'll paste the whole code on...
I couldn't think of a good title for the thread, hence the really bad one, sorry...
I'm currently working on a "tiny" game to learn some of the basics in C. In short, the computer makes an array...
Ahh, found it... the [] in void fyllArray(Secret hemligtTal[]) caused the error, fixed it now!
Ahh, thanks, stupid me didnt think of that :)
Now it works, and it might even be a simpler solution than the one the teacher showed us.
#include <stdio.h>
#include <time.h>
#define...
its going from 0 to 10, so right now they duplicate almost every time...
Hello,
To begin with, i'm new to programming so try to keep it simple :)
We're making a mastermind game at school, and i've done some of it already, but i need help with how to generate 4...