Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1024059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:43:23+00:00 2026-05-16T11:43:23+00:00

hello i got a problem with reading from a file, i am trying to

  • 0

hello i got a problem with reading from a file, i am trying to read from a file using fscanf() and i cant seem to sort it out.
i try to read the file line by line and putting the string in a variable (buffer) each time but i cant understand how the while loop is suppose to be looking like
thanks in advance

the file that i want to read from is a txt file with this format: first line :”1234,abc,etc” second line : “2432,fjh,etc” and more lines like those i want to be able to use the fscanf method inorder to put in each loop the all line lets say “1234,abc,etc” in my string variable and so on till i dont have any more lines to read from

this is what i managed to gather so far (ofc its not the currect way to write it):

char* buffer[100]; 
while (fscanf(FILE *finput,"%s",buffer)!=something) 
{ 
    printf("%s",buffer); 
}

i want this code to be able to print all of the lines in my code if you would be able to correct my errors i will greatly appriciate it

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:43:24+00:00Added an answer on May 16, 2026 at 11:43 am

    I feel like you should read some of these great topics first:

    Trouble reading a line using fscanf()

    Reading file using fscanf() in C

    fscanf multiple lines [c++]

    There are plenty of reasons why you should use fgets or something else instead.

    Quoting from this place:

    fscanf() is a field oriented function and is inappropriate for use in a robust, general-purpose text file reader. It has two major drawbacks:

    • You must know the exact data layout of the input file in advance and rewrite the function call for every different layout.
    • It’s difficult to read text strings that contain spaces because fscanf() sees space characters as field delimiters.

    If you know the size of file you’re trying to read, you could use fread(), which is block oriented.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i have got a problem, if I try to display maps with using
Hello i got a problem using Apache-Tomcat v6.0.29. The Problem My application uses apache
hello i got a problem, whenever i try to write any simple thing inside
Hello I've got a problem accessing Oracle DB from our datacenter through a tunnel.
im using jqueryui dialog but there's a problem upon loading it from other file.
Hello I've got a bit of a problem. I'm trying to use WMI to
hello i got a problem using valgrind when i use it with valgrind --leak-check=full
Hello stackoverflow people! I've got a problem which I haven't been able to solve
I got this code ` // // prints out Hello World! // hello_world(); //First
hello i got a problem with returning an array of linklists in c lets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.