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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:35:42+00:00 2026-05-18T12:35:42+00:00

For a homework assignment, we are working on CSV parser. I’m trying to get

  • 0

For a homework assignment, we are working on CSV parser. I’m trying to get things working, but I’ve run into an issue. I can’t seem to assign a value to “field” value in the struct. In the code they provided they have:

typedef char f_string[MAX_CHARS+1] ;    /* string for each field */

    typedef struct {
        int nfields;                        /* 0 => end of file */
        f_string field[MAX_FIELDS];         /* array of strings for fields */
    } csv_line ;

With the above constants defined at 20 and 15. Looking at what they have, the struct holds and int, and it holds an array that should be populated with the f_string typedef they defined earlier. Alright, cool. I tried to do it this way:

f_string test = "Hello, Bob";
f_string testAgain = "this is dumb, k?";
f_string anArray[MAX_FIELDS] = {*test, *testAgain};

csv_line aLine;
aLine.nfields = 3;
aLine.field = *anArray;

When I make “anArray”, if I don’t have the dereferences to test and testAgain, I get warnings about making integers to pointers without a cast. So I leave them in. But the line:

aLine.field = *anArray;

Returns the error: “csv.c:87: error: incompatible types in assignment” with or without the pointer there… so I’m not sure how I should be assigning that variable? Help would be appreciated!

  • 1 1 Answer
  • 1 View
  • 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-18T12:35:43+00:00Added an answer on May 18, 2026 at 12:35 pm

    You can’t assign to an array using =. See this question for a more detailed explanation.

    You’ll need to copy each string using the strcpy (or the safer strncpy) function:

    for (int i = 0; i < aLine.nfields; ++i)
    {
      strncpy(aLine.field[i], anArray[i], MAX_CHARS);
    }
    

    Also, the test code you provide isn’t going to do what you expect.

    f_string test = "Hello, Bob";
    f_string testAgain = "this is dumb, k?";
    f_string anArray[MAX_FIELDS] = {*test, *testAgain};
    

    This will copy the first character of test and testAgain. You need to do something like:

    f_string test = "Hello, Bob";
    f_string testAgain = "this is dumb, k?";
    f_string anArray[MAX_FIELDS];
    strcpy(anArray[0], test);
    strcpy(anArray[1], testAgain);
    

    Or just:

    f_string anArray[MAX_FIELDS] = {"Hello, Bob", "this is dumb, k"};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a homework assignment and I ran into a little snag. I'm
I am working on a homework assignment and I'm trying to figure out a
I am working on a homework assignment for my into to programming class that
I am working on a homework assignment that deals with binary search trees and
I'm working on a homework assignment in which I'm required to use char arrays
I'm working on a homework assignment (a project), for which one criterion is that
I'm working on a small homework assignment and I'm supposed to make a food
I am working on this homework assignment and I am stuck on what I
I am working on a homework assignment looking at inheritance in java. I am
For a homework assignment, I'm working with the following. It's an assigned class structure,

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.