1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Newbie Question

Discussion in 'C' started by TFLNemesis, Mar 17, 2008.

  1. TFLNemesis

    TFLNemesis New Member

    Joined:
    Mar 17, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi All

    I have a newbie problem, I am very new to C programming and am studying it as part of a degree course in the uk. We have to use C specifically not C# or C++.

    I am currently running Bloodshed Dev-C++ V4.9.9.2 on Windows XP Professional Version 2002 Service pack 3 V.3264

    My problem is this;

    Having written and compiled a simple program;
    Code:
    #include <stdio.h>
    
    int main(void)
    {     float x,y  ;                                    
          printf(" Please input 2 integers\n"); 
          scanf("%f %f", &x, &y);                
          printf("\nThe two integers are:\n %f %f\n",x, y);
          system("PAUSE");                               
          return 0;
    }
    
    tested it and it works how i want, i then edited the program to;

    Code:
    #include <stdio.h>
    
    int main(void)
    {     float x,y  ;                                   
          printf("Please input 2 integers\n");
          scanf("%f %f", &x, &y);               
          printf("\nThe two integers are:\n%f %2f\n",x,y);
          system("PAUSE");                                
          return 0;
    }
    only a simple variation on the original program, but when i compile the new edited program (after having saved it as a new source file) it acts exactly as the original unedited program within Dev-C++.

    Closing out Dev-C++ and reopening the source file makes no difference, even rebooting my computer and then opening the source file again with Dev-C++ makes no difference, the executed program acts exactly as the original unedited program.

    This is driving me nuts and causing my work to take 3-4 times as long as it should.

    Does anyone have any idea where i am going wrong adn what i need to do to stop this happening?

    Thanks TFLNemesis
     
    Last edited by a moderator: Mar 18, 2008
  2. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    difference is there
    first program layout
    Code:
    
    asadulla ~/test> g++ temp6.cpp
    execution gcc-3.3.1/g++ (gprs/pcusa_passport_sas)
    asadulla ~/test> ./a.out
    Please input 2 integers
    12 34
    
    The two integers are:
    12.000000 34.000000
    
    second program senario is

    Code:
    
    asadulla ~/test> g++ temp6.cpp
    execution gcc-3.3.1/g++ (gprs/pcusa_passport_sas)
    asadulla ~/test> ./a.out
     Please input 2 integers
    12 34
    
    The two integers are:
     12.000000 34.000000
    
    
    
     

Share This Page