Sponsored Content
Top Forums Programming How to take input from cmd line into file Post 302396594 by abubacker on Friday 19th of February 2010 12:04:14 AM
Old 02-19-2010
Hope that this is the simplest input output program in C , using getchar and putchar

Code:
#include<stdio.h>
main()
{
        int c ;
        while((c=getchar())!=EOF)
                putchar(c);
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh: cmd output to input of another script

I want to write a script in KSH that takes the output of one command and redisplays it. Something like: while true do read inpt date +"%I:%M:%S %p <-> $inpt" done and then some how get the output of the ping command to redirect to the input of this script. does that make sense? (2 Replies)
Discussion started by: IMTheNachoMan
2 Replies

2. Shell Programming and Scripting

sed to read line by line and input into another file

I have two files. Fileone contains text string one text string two text string three Filetwo contains Name: Address: Summary: Name: Address: Summary: Name: Address: Summary: I would like to use sed to read each line of file one and put it at the end of the summary line of file... (3 Replies)
Discussion started by: dolacap
3 Replies

3. Shell Programming and Scripting

sed command works from cmd line to standard output but will not write to file

Hi all .... vexing problem here ... I am using sed to replace some special characters in a .txt file: sed -e 's/_<ED>_/_355_/g;s/_<F3>_/_363_/g;s/_<E1>_/_341_/g' filename.txt This command replaces <ED> with í , <F3> with ó and <E1> with á. When I run the command to standard output, it works... (1 Reply)
Discussion started by: crumplecrap
1 Replies

4. Shell Programming and Scripting

How to input the return value (1 or 0) ping cmd to a variable

Hi I would like to ask about my plan script I have this several workstation want to monitor and execute a command without logging it we use "rsh $host "<command>" i create csh script using foreach to loop my several workstation, my problem with the rsh command is if it encounter a... (3 Replies)
Discussion started by: jao_madn
3 Replies

5. UNIX for Dummies Questions & Answers

input URL into cmd with a alias

I want to run wget "URL" -SO /dev/null 2>&1 | grep "HTTP/\\|Age:\\|Last-Modified:" but I want a alias so I can just type mywget and the URL and it will put the url in the right place and give me the output that I want without having to type that over and over again.:wall: I am newbie to all... (2 Replies)
Discussion started by: splitradius
2 Replies

6. Shell Programming and Scripting

run cmd based on input

Hi, This is what I have so far but it seems like a lot more than is necessary because....for example...user presses 2 or 3 ..... the script does the *same* thing it just depends on the directory it has to access....how can I improve this so that the code from 2 and 3 is only put once...? ... (4 Replies)
Discussion started by: holyearth
4 Replies

7. UNIX for Dummies Questions & Answers

passing input into a cmd line that's waiting for a response

Hi, I am writing a little script to update a parameters on JMQ. however the JMQ requires a "y" confirmation to be input as part of the cmd I am running. However I want run this script to offline with no input from a user. it works if a I create a file with with just y in it and pass that in... (3 Replies)
Discussion started by: shropshirehobbi
3 Replies

8. Shell Programming and Scripting

Curl - input line by line from text file

Hi, I've got a text file with hundreds of lines I need to upload to an API via curl, one by one. The text file is like: 2012-08-01 10:45,124 2012-08-02 10:45,132 2012-08-03 10:45,114 I want to get curl to go through the text file sending a post for each line. like: curl --request... (0 Replies)
Discussion started by: emdeex
0 Replies

9. Programming

C++ Input File line by line

Hi there, I need to read some data from a file with string and number that is similar to this: word1 0.0 1.0 0.0 word3 word4 0.0 0.0 -1.0 word1 0.0 0.0 1.0 word5With this code: #include<iostream> #include<fstream> #include<string> using namespace std; int main() ... (5 Replies)
Discussion started by: Giordano Bruno
5 Replies

10. How to Post in the The UNIX and Linux Forums

Read a json file passed as cmd line argument

usage: myscript.sh config.json config.json: { "HOST":"abc", "DB_NM":"xyz", "USR_NM":"asd", "PWD":"xxx", ......... ......... ......... ........ } myscript.sh: (2 Replies)
Discussion started by: RGRT
2 Replies
PUTC(3) 						   BSD Library Functions Manual 						   PUTC(3)

NAME
fputc, putc, putchar, putc_unlocked, putchar_unlocked, putw -- output a character or word to a stream LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> int fputc(int c, FILE *stream); int putc(int c, FILE *stream); int putchar(int c); int putc_unlocked(int c, FILE *stream); int putchar_unlocked(int c); int putw(int w, FILE *stream); DESCRIPTION
The fputc() function writes the character c (converted to an ``unsigned char'') to the output stream pointed to by stream. putc() acts essentially identically to fputc(), but is a macro that expands in-line. It may evaluate stream more than once, so arguments given to putc() should not be expressions with potential side effects. putchar() is identical to putc() with an output stream of stdout. The putc_unlocked() and putchar_unlocked() functions provide functionality identical to that of putc() and putchar(), respectively, but do not perform implicit locking of the streams they operate on. In multi-threaded programs they may be used only within a scope in which the stream has been successfully locked by the calling thread using either flockfile(3) or ftrylockfile(3), and may later be released using funlockfile(3). The putw() function writes the specified int to the named output stream. RETURN VALUES
The functions, fputc(), putc() and putchar() return the character written. If an error occurs, the value EOF is returned. The putw() func- tion returns 0 on success; EOF is returned if a write error occurs, or if an attempt is made to write a read-only stream. SEE ALSO
ferror(3), fopen(3), getc(3), stdio(3) STANDARDS
The functions fputc(), putc(), and putchar(), conform to ANSI X3.159-1989 (``ANSI C89''). The functions putc_unlocked() and putchar_unlocked() conform to ISO/IEC 9945-1:1996 (``POSIX.1''). HISTORY
The functions putc(), putchar(), and putw() first appeared in Version 6 AT&T UNIX. The function fputc() appeared in Version 7 AT&T UNIX. BUGS
The size and byte order of an int varies from one machine to another, and putw() is not recommended for portable applications. BSD
May 6, 2010 BSD
All times are GMT -4. The time now is 06:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy