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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:23:13+00:00 2026-06-15T00:23:13+00:00

I was hoping if you can help me with some input and 2 dimensional

  • 0

I was hoping if you can help me with some input and 2 dimensional arrays for this method of a program I am writing for an assignment. The programming language is C I got some input parameters:

FILE * ifp = input file pointer, opened up in main, opened a txt file with a format of 3 strings per line

char ** firstTokens, middleTokens = 2 dimensional char arrays, I want them to hold the first two strings minus expected punctuation at the end of each string (such as commas and periods). Planned to be an output parameter.

char * lastLetter = The first letter of whatever string is in the last column per line in the txt file. Planned to be an output parameter.

int numberOfLines = number of lines I’m expecting to read from the text file

This is the call to the method in my main function:

readLine(ifp, firstTokens, middleTokens, lastLetter, numberOfLines);

I think my problem is with getting the firstTokens and middleTokens correctly, as I’m always getting compiler errors and segmentation faults in my edits. Some help/clarifications to the errors would be greatly appreciated.

void readLine(FILE * ifp, char ** firstTokens, char ** middleTokens, char* lastLetter, int numberOfLines)
{
    char* tempFirst;
    char* tempMiddle;
    char* tempLast;
    char delim[4];
    delim[0] = '.';
    delim[1] = '\0';
    delim[2] = '\n';
    delim[3] = ',';
    int i;

    for(i = 0; i < numberOfLines; i++)
    {
        fscanf(ifp, "%s %s %s", tempFirst, tempMiddle, tempLast);
        *firstTokens[i] = strtok(tempFirst, delim);
        *middleTokens[i] = strtok(tempMiddle, delim);
        lastLetter[i] = tempLast[0];
    }
}
  • 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-15T00:23:14+00:00Added an answer on June 15, 2026 at 12:23 am

    You’ll need to allocate storage for tempFirst, tempMiddle, and tempLast. fscanf writes to these pointers, assuming you’ve provided sufficient memory at them.

    #define MAX_NAME_LEN (20) /* change this as required */
    ...
    char tempFirst[MAX_NAME_LEN];
    char tempMiddle[MAX_NAME_LEN];
    char tempLast[MAX_NAME_LEN];
    ...
    fscanf(ifp, "%s %s %s", tempFirst, tempMiddle, tempLast);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hoping somebody can help me with this. For some reason, the following form code
hoping someone can help shed some light on this for me. Im working on
I am hoping that someone can help shed some light on this issue I've
Am having some trouble with the SkyDrive download process and hoping you can help
Hoping you can help as im not sure how to approach this. Cant seem
I'm hoping someone can help on this one, I have created a custom object
I'm hoping someone can help me as I've been stuck on this problem for
I'm working on some homework and receiving the strangest error. Hoping you can help.
I am hoping that I can get some help with my learning and find
I am developing my first UI C# program. I am hoping for some help.

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.