Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi, can i get help to debug the following C program? The value is expected like this but it's actually like this Please help!!! If
Hi, can i get help to debug the following C program?
The value is expected like this
but it's actually like this
Please help!!!
If it's okay, please provide a little explanations.
Thanks a lot
The code is here for convenience.
#include#include #include char *names[10]; int num_names = 0; void add_name(char *name) { // Allocate space for a copy of the name names[num_names] = malloc(sizeof(name)); // Copy name to new area in memory strcpy(names[num_names], name); // Add one to num_names num_names++; } void print_names(void) { for (int i = 0; i #include
#include #include char *names [10]; int num_names = 0; void add_name(char *name) { // Allocate space for a copy of the name names [num_names] = malloc(sizeof(name)); // Copy name to new area in memory strcpy(names [num_names], name); // Add one to num_names num_names++; } void print_names (void) { for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started