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

  • Home
  • SEARCH
  • 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 7912131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:30:52+00:00 2026-06-03T13:30:52+00:00

This is so stupidly simple but I’m just having issues with it. A text

  • 0

This is so stupidly simple but I’m just having issues with it.

A text file has a header,

e.g.,

# Avizo BINARY-LITTLE-ENDIAN 2.1

define Lattice 496 384 470

Parameters {
    AlignTransform {
        slice0000 0 -0 -30 -1,
        slice0001 0 -0 -30 -1,
        slice0002 0 -0 -30 -1,

And I’m trying to read each of these lines using fscanf.

   int i;
   for (  i = 0; i < 10; i++ ) {
     fscanf(fp, "%s\n", buf);  
     printf("%d) %s\n",i,buf);
   }

resulting in this

0) #
1) Avizo
2) BINARY-LITTLE-ENDIAN
3) 2.1
4) define
5) Lattice
6) 496
7) 384
8) 470
9) Parameters

So it’s parsing the whitespace instead of newlines. Not sure what’s happening.

  • 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-06-03T13:30:53+00:00Added an answer on June 3, 2026 at 1:30 pm

    The %s specifier in fscanf reads words, so it stops when reaching a space.

    Use fgets to read a whole line.

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

Sidebar

Related Questions

I made this stupidly simple PHP file containing <?php class stuff { private $var;
This seems so stupidly simple, but I can't figure it out. I'd like to
I'm sorry if there is a stupidly simple answer to this question, but I've
This is probably a stupidly simple question, but I'm stuck. I had created a
I'm sure it's stupidly easy, but how can I replace just the text within
This is probably something really stupidly simple.. I have a drop down list bound
this might be really simple and I've tried searching but I haven't been able
I'm sure this is a stupidly simple question, so I apologize in advance. I'm
This is probably a stupidly easy question for a Rails person but is causing
This is a stupidly trivial question, but I can't seem to find a proper

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.