The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
redirection DNAx86 Shell Programming and Scripting 9 04-18-2008 02:24 PM
sed redirection myle UNIX for Dummies Questions & Answers 3 03-12-2008 07:04 PM
csh stderr redirection jolok Shell Programming and Scripting 0 04-15-2005 10:03 AM
I/O redirection within a coprocess Mugin Shell Programming and Scripting 4 10-21-2003 08:17 AM
redirection to tty** with cat zorro UNIX for Dummies Questions & Answers 1 11-02-2001 11:23 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-11-2001
Shallon1 Shallon1 is offline
Registered User
  
 

Join Date: Dec 2001
Posts: 1
Question 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&lt;input

and it does not print 5 and 4, it prints some jumble of numbers.
Please help!
Shallon1
  #2 (permalink)  
Old 12-12-2001
auswipe's Avatar
auswipe auswipe is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Wide Awake Wylie, Texas
Posts: 535
Quote:
Here is my problem. I don't know make this redirection thing work. The output file (called output.c) looks like this

#include

int main()
{
int k;
int m;

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

return 0;
}
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".
  #3 (permalink)  
Old 12-12-2001
shaik786
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Hi!

What exactly are you trying to do???
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

Last edited by shaik786; 12-12-2001 at 08:00 AM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0