Thread: Trying to scan in user input after the '<' not working on gcc.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2017
    Posts
    2

    Trying to scan in user input after the '<' not working on gcc.

    I am reading in a csv file, outputting a txt file and also reading in a text file to search for the keys that I have to output into the txt file.

    So basically this is my code.
    /* This is to read in the CSV file" */
    Code:
    while(fscanf(Data_input,"%d; %[^\n]",&weight,num) == 2){         
                    insert(ptr,word,num);
            }
    /*Now I want to read in the search key where read_word is declared as char array of size 500*/

    Code:
    while(scanf("%[^\n]", read_word) == 1){
            printf("%s\n", read_word);
        }
    The command on stdin should look like this after compilation

    ./aout read.csv out.txt < search.txt

    I am unable to read the search.txt. I tried using fscanf and now I am trying to use just scanf to see if anything happens but the command reads out null as there is no such this that exists on argv[4]? I know its not reading in the file since when I print it out it prints null and exits =(
    Last edited by Pdave7; 09-04-2017 at 01:38 AM. Reason: Not in line

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. user input bounds not working
    By intex in forum C Programming
    Replies: 2
    Last Post: 11-24-2012, 08:06 PM
  2. Replies: 2
    Last Post: 03-05-2012, 10:35 AM
  3. Replies: 3
    Last Post: 11-01-2010, 08:22 PM
  4. C Function won't scan for user inputted value
    By kevin250 in forum C Programming
    Replies: 10
    Last Post: 10-21-2010, 10:41 PM
  5. User-input not working
    By Serejai in forum C++ Programming
    Replies: 6
    Last Post: 08-22-2004, 06:55 PM

Tags for this Thread