help regarding linking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
      I am a newbie at using gcc.  I wanted to write functions and the main file
in different files

 I am using the following to compile
gcc -c file1.c
gcc  -c file2.c
gcc file1.o file2.o
a.out
2.00000 1.90000

I am not able to understand why that is the output. But if write the
function to_print in file1.c and compile, it works normally.
If I replace all floats  in both files by double it works

What is happening? Am I compiling them wrong.


/*----------- file1.c-------------*/
#include<stdio.h>
#include<stdlib.h>

int main()
{
    float a,b;
    a=1.2;
    b=1.3;
    to_print(a,b);
    return 0;
}
---------------file2.c-------------
#include<stdio.h>
void to_print(float a, float b)
{
    printf("%f , %f \n", a,b);

}



-regards
Radha Krishna Ganti

--
Radha Krishna Ganti
EE-Grad Student
Univ. Of Notre Dame



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux