Thread: getting an error ???

  1. #61
    Registered User
    Join Date
    Aug 2007
    Posts
    59
    Quote Originally Posted by matsp View Post
    Code:
    scanf("%d",&aperture);
    This should be %f, not %d.

    And you should relly add an f on the end of all your numbers comparing the aperture (and you will need to add a .0 to the ones that don't have a . in them, as for example 4f isn't a valid float, 4.0f is.

    --
    Mats
    But if ((aperture==1.2f. . . ) doesn't work

  2. #62
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by ki113r View Post
    But if ((aperture==1.2f. . . ) doesn't work
    In what sense does it not work. It works on my machine.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #63
    Registered User
    Join Date
    Aug 2007
    Posts
    59
    Quote Originally Posted by matsp View Post
    In what sense does it not work. It works on my machine.

    --
    Mats
    It won't compile for me , it gives me an error.

  4. #64
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by ki113r View Post
    It won't compile for me , it gives me an error.
    Which error?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #65
    Registered User
    Join Date
    Aug 2007
    Posts
    59
    ..................
    Last edited by ki113r; 09-05-2007 at 10:03 AM.

  6. #66
    Registered User
    Join Date
    Aug 2007
    Posts
    59
    Quote Originally Posted by matsp View Post
    Which error?

    --
    Mats
    Lexican Error

  7. #67
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by ki113r View Post
    Lexican Error
    I've never heard of a compiler giving a "lexican" error. When we ask you to post the error, it's not to make you look stupid, but because it tells us exactly where the error is and more importantly *what* the error is.
    So, copy and paste please!

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  8. #68
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    If you don't immediately remove those goto's, I'm not going to help you further. goto's are NOT the way to solve the problem.

    Also, post the if-statement that gives your error (with the f's).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #69
    Registered User
    Join Date
    Aug 2007
    Posts
    59
    Quote Originally Posted by QuantumPete View Post
    I've never heard of a compiler giving a "lexican" error. When we ask you to post the error, it's not to make you look stupid, but because it tells us exactly where the error is and more importantly *what* the error is.
    So, copy and paste please!

    QuantumPete
    Yeh no problem Pete . Thats what it gave me , lemme try it again ...
    wow it worked now . This is crazy :-|

  10. #70
    Registered User
    Join Date
    Aug 2007
    Posts
    59
    Unfortunately it still does the infinite loop Btw this is how it looks when I run it :
    http://img119.imageshack.us/img119/3227/coders4.jpg
    Last edited by ki113r; 09-05-2007 at 09:07 AM.

  11. #71
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by ki113r View Post
    wow it worked now . This is crazy :-|
    Forgot to save before compiling?

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  12. #72
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Unless you have changed it just this moment, the scanf() still needs to be %f, not %d. If you scanf with %d and enter 1.2 (or anything else with a . in it), scanf will get stuck on the . in the input, and since you have no code to consume the remaining input, you get an infinite loop.

    I did suggest to use fgets() and sscanf(), rather than scanf(), because it avoids many of the problems of "garbage in the input causes strange problems".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #73
    Registered User
    Join Date
    Aug 2007
    Posts
    59
    Quote Originally Posted by matsp View Post
    Unless you have changed it just this moment, the scanf() still needs to be %f, not %d. If you scanf with %d and enter 1.2 (or anything else with a . in it), scanf will get stuck on the . in the input, and since you have no code to consume the remaining input, you get an infinite loop.

    I did suggest to use fgets() and sscanf(), rather than scanf(), because it avoids many of the problems of "garbage in the input causes strange problems".

    --
    Mats
    I have to use scanf , its one of the requirements from my lecturer

  14. #74
    Registered User
    Join Date
    Aug 2007
    Posts
    59
    Wohoo , it sort of worked
    Code:
    C:\Users\Ben\dm\bin>test3
    
    Enter Exposure Time: 12
    The selected Exposure time is 12
    Please enter the aperture size 1.4
    Invalid aperture=1610612736
    Please Try Again
    Please enter the aperture size 12
    You have entered a correct value

  15. #75
    Registered User
    Join Date
    Aug 2007
    Posts
    59
    Quote Originally Posted by matsp View Post
    If you don't immediately remove those goto's, I'm not going to help you further. goto's are NOT the way to solve the problem.

    Also, post the if-statement that gives your error (with the f's).

    --
    Mats
    I was just trying it with gotos , in case its the while loop thats causing the problem . , but it seems to be fine

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM