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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:00:24+00:00 2026-05-19T17:00:24+00:00

I have a bit of a problem. I am barely starting out with C,

  • 0

I have a bit of a problem. I am barely starting out with C, (comming from a C# background) and I am having problem with double pointers.

I have a structure as follows:

#ifndef __PROCESSINFO_H
#define __PROCESSINFO_H

struct ProcessInfo
{
   int ProcesId;
   int Priority;
   int ExecutionTime;
   int EllapsedTime;
   char* ProcessName;
}; 

struct ProcessInfo *ProcessInfo_Allocate(int processId, char *processName, int priority, int executionTime);
void ProcessInfo_ToString(struct ProcessInfo *processInfo);
void ProcessInfo_Dispose(struct ProcessInfo *processInfo);

#endif

Implementation:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "processinfo.h"

struct ProcessInfo *ProcessInfo_Allocate(int processId, char *processName, int priority, int executionTime)
{
    struct ProcessInfo *processInfo;
    processInfo = (struct ProcessInfo *)malloc(sizeof(struct ProcessInfo));
    processInfo->ProcessId = processId;
    processInfo->ProcessName = processName;
    processInfo->Priority = priority;
    processInfo->ExecutionTime = executionTime;
    processInfo->EllapsedTime = 0;

    return processInfo;
}

void ProcessInfo_ToString(struct ProcessInfo *processInfo)
{
    printf(" %6i %6i %10i %10i, %25s", processInfo->ProcessId, processInfo->Priority, processInfo->ExecutionTime, processInfo->EllapsedTime, processInfo->ProcessName); 
}

void ProcessInfo_Dispose(struct ProcessInfo *processInfo)
{
    if(processInfo != NULL)
    {
        if(processInfo->ProcessName != NULL)
        {
            free(processInfo->ProcessName);
        }

        free(processInfo);
    }
}

so now I have to manage a whole lot of ProcessInfo instances. I wrote another structure which would hold a pointer to a pointer to the ProcessInfo sturcture because i thought that I can increase and decrease it in size as needed (without too much hassle);

#ifndef __SCHEDULER_H
#define __SCHEDULER_H

struct Scheduler
{
    struct ProcessInfo** Processes;
};

struct Scheduler* Scheduler_Allocate(void);

#endif

So the question is how do I initialize the **Processes member inside the Scheduler_Allocate method? How do I add stuff to it?

  • 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-19T17:00:24+00:00Added an answer on May 19, 2026 at 5:00 pm
    struct Scheduler s;
    s.Processes = malloc(sizeof(struct ProcessInfo*) * size);
    s.Processes[0] = ProcessInfo_Allocate(...);
    
    // Add more items:
    s.Processes = realloc(malloc(sizeof(struct ProcessInfo*) * (size + 1));
    s.Processes[size] = ProcessInfo_Allocate(...);
    size++;
    

    Also see my example here:

    Array of C structs

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

Sidebar

Related Questions

I have a bit of a problem i am trying to sort out. I
I have bit of a problem with understanding PHYSICAL_ADDRESS structure in WDK. I thought
i'm very new to sencha.i have a bit problem in accessing the data from
I'm having a bit of problem with casting and datagrids. I have a LINQ
Hey guys, I have a bit of a problem. I get values from textarea
I have a little bit problem with reading datas from checkboxes. {foreach value=artist2 from=$artist}
I have a bit of problem when trying to validate my page as HTML5.
I have a bit of a problem that I can't seem to code my
I have a bit of a problem. I am trying to do the following
I have a bit of a problem building my project. I'm getting the bellow

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.