|
I've already got some code to read a text file using fscanf() , and now I need it modified so that fields that were previously whitespace-free need to allow whitespace. The text file is basically in the form of:
title: DATA
title: DATA
etc...
which is...
Started by Graphics Noob on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Fgets() use the %[ conversion specifier (with the "exclude option"):
char buf[100]; fscanf(stdin, "%*sI highly suggest you stop using fscanf() and start using fgets() (which reads a whole line to parsing non-exactly-formatted input....
|
|
How can I read the contents of stdin (up until EOF) into a string in PHP?
Started by zak23 on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Ended up figuring....
You can test for the EOF information.
Fgets() , fgetc() , fscanf() ) and pass in STDIN as the file path (or php://stdin , depending on how new your version of PHP is).
Use some of the file reading functions (e.g.
|
|
I'm looking to write a pair of utilities that read in a newline separated list of integers on stdin and output their binary (4 byte) equivalent to stdout, and vice versa.
My first thought was a simple bash/linux command that would do this, but I was unable...
Started by Rich on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Beware of endianness the stdin....
:)
#include <stdio.h> int main () { int x; while (fscanf(stdin, "%i", &x)) { fwrite(&x, sizeof(x), 1 of fscanf() to read each integer, followed by a fwrite() to write it out should work.
|
Ask your Facebook Friends
|
Is that even possible ?
Lets say that the code has a lot of scanf lines. Instead of manually running and adding values by hand when debugging, is it possible to "feed" stdin with data so that when the scanf starts reading, it will read the inputted data...
Started by Zka on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
So that it can already handle file IO as opposed to just console IO; then when you want to read from stdin or write) { infile = stdin; outfile = stdout;....
Might want to consider rewriting your program to use fscanf , fprintf , etc.
|
|
The situation:
I have jpeg images stored inside archives (sometimes encrypted) on CDs or DVDs. It's a pain to copy these onto the hdd and extract them and view them.
Proposed solution:
I want to write a program that takes a input only from stdin, and ...
Started by H_TeXMeX_H on
, 12 posts
by 5 people.
Answer Snippets (Read the full thread at linuxquestions):
I looked at the code, and I don't know if it is possible to modify it to accept stdin input.
But it is limited in the number of archives types it can open and it can't read from stdin.
|
|
On Fri, 16 Jan 2009 00:48:57 +0000 (UTC), Vincent Lefevre <vincent+news@vinc17.org
I posted the following message to the Austin Group mailing-list about
(IMHO) a contradiction between POSIX.1-2008 and the ISO C standard.
I haven't had any answer...
Started by Vincent Lefevre on
, 3 posts
by 2 people.
Answer Snippets (Read the full thread at omgili):
But if you write a test program you'll find that
glibc fscanf() returns 1 for an input failure enough data in it for one conversion, so that
fscanf() gets an EAGAIN error when it tries to read.
|
|
On Sun, 7 Jun 2009 10:48:58 -0700 (PDT), "eap.britzkrieg" <eap.blitzkrieg@gmail.com
Hello,
I wanna read characters from stdin as long as I put them on it from
keyboard.
For example:
If I use
fscanf(stdin, "%c", &c);
when I put 'w', for instance...
Started by eap.britzkrieg on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at omgili):
(Using Windows ....
You need a function that is specific to your OS .
On Sun, 07 Jun 2009 18:10:19 GMT, "BartC" <bartc@freeuk.com
"eap.britzkrieg" <eap.blitzkrieg@gmail.comnews:622aba34-7dd3-4b99-9fd8-da6f51f0aba3@n19g2000vba.googlegroups.com.. .
|
|
Note: I completely reworked the question to more properly reflect what I am setting the bounty for. Please excuse any inconsistencies with already-given answers this might have created. I did not want to create a new question, as previous answers to this...
Started by DevSolar on
, 9 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Maybe just set the stream's error indicator?
I am", &x); ungetc('9', stdin); scanf("%d", &y); printf("%d, %d\n", x, y);
If the input is "100 of PL22.11 (ANSI "C"), on comp.std.c shed some light....
What fscanf() should do if ungetc() fails.
|
|
Dear all,,
I want to read line-by-line from a given input file,, process each line (i.e. its words) and then move on to other line...
So i am using fscanf(fptr,"%s",words) to read the word and it should stop once it encounters end of line...
but this ...
Started by RBA on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
*/ int n = fscanf(stdin, "%" xstr(MAXLINE) "[^\n = fscanf(stdin, "%" xstr(MAXLINE) "[^\n]%*[^\n]", line); if (!feof(stdin)) { getchar(); } } return 0 is running in line....
Discard the rest upto and including a newline.
|
|
Best way to scan in a string What is the best way to scan in a string that HAS white spaces if I want the scan to stop once it finds a '\n' character. I need to do this both from regular user input, stdin, and from a file. Should I use scanf, fscanf, ...
Started by Matt Hintzke on
, 5 posts
by 3 people.
Answer Snippets (Read the full thread at cprogramming):
Ive looked them up multiple times and everytime I try one, something ends up being wrong with the way I try... .
Hope is the first step on the road to disappointment .
Why don't you look up each function and read the documentation on them?
scanf
fgets
Quzah .
|