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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:31:59+00:00 2026-05-30T06:31:59+00:00

I am pretty confused with pointers in C. I am finding it hard to

  • 0

I am pretty confused with pointers in C. I am finding it hard to wrap my mind around creating them and passing stuff around? I have a “Segmentation Fault: 11” error after I added code, in which previously it worked. Needed to add something. This is part of the code:

char *token2;
char *line2;
char comma_loc = 0;
int num_of_commas = 0;
char *line2[1];

while(token != NULL) { //lets make sure token has a string token
        //printf("Wats in token: %s\n", token);
        if(key==true) {
            //printf("This should be an identifier: %s\n", token);

            if(comma != true) { //added if statement, just take away if it fails, the first case is the original
            int len = strlen(token);
            iden_holder[iden_holder_count] = (char *)malloc(sizeof(char) * (len +1));
            memcpy(iden_holder[iden_holder_count], token, len +1);
            iden_holder_count++;
            key = false;
            } else {

                int len2 = strlen(token);
                line2[0] = (char *)malloc(sizeof(char) * (len2 + 1));
                memcpy(line2[0], token, len2 + 1);
                token2 = strtok(line2[0],",");
                    while(token2 != NULL) {
                            int len = strlen(token2);
                            iden_holder[iden_holder_count] = (char *)malloc(sizeof(char) * (len +1));
                            memcpy(iden_holder[iden_holder_count], token, len +1);
                            iden_holder_count++;
                            token2 = strtok(line2[0],",");
                        }
                key = false;

            }

Point of this code is to take the string within token and copy it into another token, in my case token2. I decided to use memcpy, but I am confused how to use it due to the pointers confusion. I should also note that I used strtok before this, and the code here is within in. Could it be that if I use it again that it will override the other one?

  • 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-30T06:32:00+00:00Added an answer on May 30, 2026 at 6:32 am

    Read this completely. It will help you with your basics. It did to me. 🙂

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

Sidebar

Related Questions

I'm pretty confused with the behaviour of arrays of strings when I loop them
I'm pretty confused. I have a point: x= -12669114.702301 y= 5561132.6760608 That I got
i have readed many topic but i'm pretty confused. it seems that: if ([[UIScreen
I am new to LINQ, so I am pretty confused here. I have a
im pretty confused about lambdas and actually im not even sure i need them
I'm pretty confused on how to go about this. Say I have two columns
I have to admit that I am pretty confused how annotations work in java
I am new to asp.net stuff and I am pretty confused on how to
I am pretty confused with the plethora of OLEDB providers found in creating a
I am pretty confused about the ASP.NET MVC project architecture. In ASP.NET WebForm I

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.