Help with redirection

Here is my problem. I don't know make this redirection thing work. The output file (called output.c) looks like this

#include<stdio.h>

int main()
{
int k;
int m;

print f("%d\n", k);
printf("%d\n", m);

return 0;
}

the input file(called input.c) is this
#include<stdio.h>

int main()
{
int k;
int m;

k=5;
m=4;

return 0;
}

I then compile the output file and do
a.out<input

and it does not print 5 and 4, it prints some jumble of numbers.
Please help!
Shallon1

The reason that you are getting a bunch of numbers is that the int vars k and m are never assigned a value. You are displaying the values of what is in the memory address of k and in the memory address of m at the time of execution. The contents of an unassigned variable at execution time is commonly referred to as "compilter garbage".

Hi!

   What exactly are you trying to do??? :confused:
   From what I've understood, you are trying to pass the values 5 and 4 from the file input to the file output. If this is what you are trying to do, your files should look like:

input:

5
4

output.c

#include < stdio.h >

int main()
{
int k;
int m;

scanf("%d", &k);
scanf("%d", &m);

printf(" %d, %d\n", k, m);

return 0;
}

ofcourse, you can go about with your C Programs also by modifying your input.c file to "printf()" 'k' and 'm' and your output.c should be like the code pasted above, but you'll have to use pipes:
input | output

and just one more thing, check your uninitialized variables!!!

Regards
SHAIK