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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:29:09+00:00 2026-06-05T20:29:09+00:00

I am a new C programmer and the pointers + arrays are messing me

  • 0

I am a new C programmer and the pointers + arrays are messing me over a lot. I don’t get any errors and the code runs fine…until somewhere in the middle the code starts acting up because some element in an array is set to something other than I wanted it to be. I wanted to know if there is a program that visualizes the memory of the code after it has finished running?

E.g after I run:

#include<stdio.h>
int main(){
    int array[2] = {0,1};
    array[1] = 4;
    printf("%d\n",array[1]);
    }

It will show a block of memory where array has two elements with 0 and 4 .

Right now to avoid running into a problem where the array contains elements from previous action I clear the memory of that array by doing:

memset(tokenized,0,MAX_CHARS);

It seems to work, but I don’t know if its actually doing what I think it’s doing at the back end.

Edit:
I am using Valgrind now and I just want to know, how do I know what line the error is referring to?
For example I got this:

==24394== Source and destination overlap in strncpy(0x7ff000006, 0x7ff000006, 6)
==24394==    at 0x4C2C236: strncpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24394==    by 0x400D8A: tokenize_quotes (in /home/zee/Documents/seng265/repos/assignment2/a.out)
==24394==    by 0x40184E: main (in /home/zee/Documents/seng265/repos/assignment2/a.out)
==24394== 
==24394== Conditional jump or move depends on uninitialised value(s)
==24394==    at 0x4C2C007: strcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24394==    by 0x400E06: tokenize_quotes (in /home/zee/Documents/seng265/repos/assignment2/a.out)
==24394==    by 0x40184E: main (in /home/zee/Documents/seng265/repos/assignment2/a.out)
==24394== 

But I don’t know what line the error is on? I know its something about strcpy
Thanks!

  • 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-05T20:29:10+00:00Added an answer on June 5, 2026 at 8:29 pm

    Use Valgrind:

    Valgrind is a GPL’d system for debugging and profiling Linux programs.
    With Valgrind’s tool suite you can automatically detect many memory
    management and threading bugs, avoiding hours of frustrating
    bug-hunting, making your programs more stable. You can also perform
    detailed profiling to help speed up your programs.​

    ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

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

Sidebar

Related Questions

Possible Duplicate: C++: When to use References vs. Pointers I'm pretty new programmer to
New programmer here, I am trying to understand and break down this code below
I am a new programmer. I get the following response from server. How can
So I am a new programmer and I just installed XCode on my Macbook
I am a very new programmer, I have made a couple basic applications, however
I am a new programmer, and I started in C and am now starting
I'm a new Python programmer who is making the leap from 2.6.4 to 3.1.1.
I'm a new Python programmer who is having a little trouble using 'self' in
I'm a pretty new C# programmer. I was wondering if someone can fill me
I always believed that when starting to learn a new programming language programmer must

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.