You just need an ampersand before the variable name in the scanf. When you're scanning integers, or doubles or floats for that matter, you need an & before the variable name in the scanf.
Type: Posts; User: darko886
You just need an ampersand before the variable name in the scanf. When you're scanning integers, or doubles or floats for that matter, you need an & before the variable name in the scanf.
Ahhhh!!! You are right!! I was initializing it again within the if. I understand now why it wasn't working. Thanks so much!!! I now just have it initialize once at the beginning and then I erased...
Ohh okay, so my variables don't exist anymore when the if stops?? Should I just copy everything after the if statements inside each if statement?? Or is there a way to keep the variables going??
...
If I commented out the whole sections like I do in the following code, the code functions properly:
#include <stdio.h>
#include <time.h>
// Constants used in the program.
#define NUM_PEGS 4...
Thank you for your help but that is not the problem. They are only allowed to have 4 numbers that they guess, so 0, 1, 2 and 3 would be appropriate. Nothing in the functionality is wrong if I take...
One last thing to demonstrate what I mean. If you tried to compile that last code I put, then run it, press 1 for single player, then type 4 numbers in from 0 to 5 as a guess, it will just go...
This is actually how it was at first, and it didn't work because it said that all of the variables were undeclared, so i initialized some of the variables outside the if statements but then when the...
And yes, here is the (looooong) code. I have some variables right at the top of main already which i tried to put inside the if statements but it wouldn't let me.
#include <stdio.h>...
Also what I have noticed is that all of my variables that are used in various functions have to be initialized outside of the if statements, even if the function that uses them is in the same if...
Hello, I had a class assingment to do to make the game "Mastermind" using my own functions. Now that's done, and I wanted to expand on it to feature a menu and multiplayer. I am fairly new to C...
Could anyone give me an example?? I am pretty new to C and don't know how I would implement your solutions
Thanks for the help, but unfortunately I'm using Windows. Any other way??
Hello,
I was wondering if there was any way that I could read in a file that is stored online. For example, if the file name was golf.txt, and it is on www.example.com/golf.txt. Is there any way I...
Hello, I am a total newbie at C programming and I am trying to make a program that renames every file in a directory. I want it to rename every file by deleting the first x amount of characters from...
Thank you very much, I was not aware that that is possible, but I will definitely look into that. I got exactly the type of answer I wanted. All you did was point me in the right direction, which is...
Hello, I am a total newbie at C programming, and programming in general. I am learning though, and I need help with deleting characters from a file name. What I am trying to do is have a program that...
How did I know it was going to be such an easy solution =D
Thank you very much for your help. I just could not see it for the life of me!
Okay, I am just starting out in C and I am having a problem with this very basic script:
/* Darko Stamenic
1/14/2010
Experiment */
#include <stdio.h>
// set known values