generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: C error

Previous Thread :: Next Thread 
tydog98 is not online. tydog98
Joined: 15 Sep 2009
Total Posts: 27704
08 Aug 2012 08:10 PM
if(sum >= 25);
{
printf("Thats a big number!");
}


else if(sum <= 25);
{
printf("That's a small number");

}

getchar();
}

It says the error is before 'else', but I can't find it

-The king of kings-
Report Abuse
L2000 is not online. L2000
Joined: 03 Apr 2008
Total Posts: 77448
08 Aug 2012 08:13 PM
I don't know much about C; however, judging based on C++, your error may be:

if (sum >= 25); {

Try removing the semicolon from the end of that?
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
08 Aug 2012 08:16 PM
if(sum >= 25)

No semicolon at the end of an if conditional.
Report Abuse
tydog98 is not online. tydog98
Joined: 15 Sep 2009
Total Posts: 27704
08 Aug 2012 08:16 PM
Thank you, I'm new to C

-The king of kings-
Report Abuse
tydog98 is not online. tydog98
Joined: 15 Sep 2009
Total Posts: 27704
08 Aug 2012 08:21 PM
Now when I enter my first number into the program, it crashes. Any help there?

-The king of kings-
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
08 Aug 2012 08:23 PM
Post the whole program.
Report Abuse
tydog98 is not online. tydog98
Joined: 15 Sep 2009
Total Posts: 27704
08 Aug 2012 08:24 PM
int main()
{
int *num1;
int *num2;
int sum;

printf("Enter your numbers: ");

scanf("%d", num1);
scanf("%d", num2);

sum = *num1 + *num2;

if(sum >= 25){
printf("Thats a big number!");
}


else if(sum <= 25){
printf("That's a small number");

}

getchar();
getchar();
}





-The king of kings-
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
08 Aug 2012 08:30 PM
You're not using scanf correctly. (I'm assuming you included stdio.h)

Those pointers have no (predictable) value, you're instructing the computer to set the memory at that value (which could be anything, including something outside your program's memory space).

Obviously that's not what you want.

int sum, num1, num2;

scanf("%d", &num1);
scanf("%d", &num2);

sum = num1 + num2;
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
08 Aug 2012 08:31 PM
That said, I'm a newbie to C so this is only my best guess at what's wrong.
Report Abuse
tydog98 is not online. tydog98
Joined: 15 Sep 2009
Total Posts: 27704
08 Aug 2012 08:35 PM
Thank you ;>

-The king of kings-
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image