C help for a beginner

Discussion in 'Software' started by Computer Acolyte, Nov 24, 2007.

  1. Computer Acolyte

    Computer Acolyte Private First Class

    I'm trying to write a program that recieves an arithmetic statment, like 2+4*7/4-4-6=, and gives you the result. Unfortunately, the program crashes, and I'm pretty sure it has to do with C's confusing handling of variables (ie it doesn't like my input). I have no idea where to start looking, so I turn to you.
    I know it's possible to do this quite conviniently with arrays, but I want to practice the material we've been taught (this is for an introduction to computer science course), and we've been told that we indeed don't have to use arrays.
     
    Last edited by a moderator: Nov 25, 2007
  2. Wookie

    Wookie Sergeant Major

    Basically you need to use a reference for the scanf

    try below and you should get a bit further

    if(!scanf("%lf ", &num1)){
     
  3. Computer Acolyte

    Computer Acolyte Private First Class

    Thanks a lot. I just can't get used to this annoying '&' symbol, that's like the third time it turned out to be the problem in one of my assignments.
    Anyway, I'll ask a mod to delete the code now so that I won't be accused of copying from myself if somebody sees this.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds