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 8560723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:20:32+00:00 2026-06-11T16:20:32+00:00

I am working on a file. I want to take each line and split

  • 0

I am working on a file. I want to take each line and split after the space.
For example if line1 has: today is monday I want to have today, is, monday separatly in order to work on them

Here is my code so far:

FILE *file = fopen ( "file1", "r" );

            if ((file != NULL ))
            {
                char line [ 128 ]; 
                while( ( fgets ( line, sizeof line, file ) != NULL ))
                {
                //tokenize the line based on space

                ??

                }
how to add text at the end of the line? i mean i have **today is monday** and i want to add for example **Yupppy** at the end of today is monday line.

            fclose ( file );

            }
  • 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-11T16:20:33+00:00Added an answer on June 11, 2026 at 4:20 pm

    To tokenize a string you can use strtok()
    Check the example in the link I post, just change the separator to space:

    ( code from the example linked )

    #include <stdio.h>
    #include <string.h>
    
    
    
    
    int main ()
    {
      char str[] ="- This, a sample string.";
      char * pch;
      printf ("Splitting string \"%s\" into tokens:\n",str);
      pch = strtok (str," ");
      while (pch != NULL)
      {
        printf ("%s\n",pch);
        pch = strtok (NULL, " ");
      }
      return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working file rename java tool, now I want to add an
The 1st example below illustrates the working code. I want to take the working
I am working with UIWebView project and I want to load an HTML file
I want my classpath to be set via a batch file. I'm working on
I'm working on a piece of homework and I want to send a FILE
I am working on an android game. I want to copy a text file
For this project I'm working on, I want to take multiple excel sheets and
I'm trying to parse each IP line from the following file (loading from the
I am working on a videos sharing web site and I want to take
Assume I have some utility that can take a number of options, each followed

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.