Thread: stop reading until newline in file pointer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    127

    stop reading until newline in file pointer

    Code:
    #include <stdio.h>
    
    
    int main()
    {
    	FILE *salesmanPtr;
    	char buffer;
    
    
    	salesmanPtr = fopen("salesman.txt","r");
    
    
    	while(salesmanPtr != "\n")
    	{
    		fscanf(salesmanPtr,"%c", &buffer);
    		printf("%c\n",buffer);
    	}
    
    
    }
    I want the reading process stop when reaching newline but salesmanPtr is a pointer. How can I modify this code to make it works?
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how can i stop having newline attached to input string?
    By Adam Rinkleff in forum C Programming
    Replies: 6
    Last Post: 07-03-2011, 10:10 AM
  2. reading newline
    By winsonlee in forum C Programming
    Replies: 4
    Last Post: 03-19-2004, 12:41 PM
  3. Stop reading from a file
    By Zalbik in forum C++ Programming
    Replies: 2
    Last Post: 12-05-2002, 05:58 PM
  4. Reading data from a file till there is a newline?
    By mackol in forum C Programming
    Replies: 18
    Last Post: 06-27-2002, 10:22 PM
  5. stop read in newline
    By Supra in forum C Programming
    Replies: 1
    Last Post: 03-04-2002, 10:43 PM