Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Newbie Question (http://www.go4expert.com/forums/newbie-question-t9406/)

TFLNemesis 17Mar2008 20:55

Newbie Question
 
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

asadullah.ansari 18Mar2008 10:06

Re: Newbie Question
 
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



All times are GMT +5.5. The time now is 07:50.