Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > stdin read

Thread Tools

stdin read

Posts: n/a
I'm trying to parse a data file that has two colums, both columns
should contain numerical values and I would like them to be stored that
way for now into two seperate arrays. I was wondering whats the best
way of doing this?


112 56
344 3
233 9

This simple program just counts the number of characters and line that
I pipe into the program and I was wondering how to take it to the next

#include <stdio.h>

int main()
    int c, nc = 0, nl = 0;

    while ( (c = getchar()) != EOF )
    if (c == '\n') nl++;

    printf("Number of characters = %d, number of lines = %d\n", nc,

    return 0;
Reply With Quote

Thread Tools

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 Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
peek at stdin, flush stdin Johnathan Doe C Programming 5 05-17-2013 04:30 PM
How to pass stdin of a C++ program to the stdin of a process createdwith ShellExecute() Ben C Programming 2 08-29-2009 09:47 PM
STDIN, OUT, ERR and $stdin, out, err - Differences? Terry Cooper Ruby 7 06-09-2009 05:48 AM
Reading from stdin then launching a program that reads from stdin strange behaviour Stefano Sabatini Perl Misc 6 07-29-2007 10:38 PM
Reading stdin once confuses second stdin read Charlie Zender C Programming 6 06-21-2004 01:39 PM