Search Result

Collapse
6 results in 0.0040 seconds.
Keywords
Members
Tags
malloc
  •  

  • why construction called when i overload the operator new in c++ by calling malloc

    hi:
    i overload the operator new, codes shown as below:

    void * __cdecl operator new(unsigned int size, const char *file, int line)
    {
    void *ptr = (void *)malloc(size);

    return ptr;
    }

    and when i want to create a class object

    CTest::CTest()
    {
    int a = 0;
    }
    CTest::~CTest()
    {
    int b = 0;
    }

    int main()...
    See more | Go to post

  • rajmitra
    started a topic How do I access data lists created by yyparse ??
    in C

    How do I access data lists created by yyparse ??

    Hello all,
    In my foo.y description I call yyparse() in main.
    ----------------------------------------
    int main(int argc, char **argv)
    {

    ...
    yyparse();
    ...

    /*Do something with a link list created by yyparse(); */
    /* Then free the list*/

    }
    --------------------------------------------

    As the comments in main show -
    How do I manipulate...
    See more | Go to post

  • Andrei Pavel
    started a topic Allocating memory to structure.
    in C

    Allocating memory to structure.

    Hello! It's my first post and my First time browsing this forum.

    I am doing a piece of homework for about a week. I'm having problems allocating memory for a structure. Segmentation fault is the error. Code from example is missing. Here are the relevant parts:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    struct file{
    	char *name;
    	int
    ...
    See more | Go to post

  • mollwollfumble
    started a topic malloc for long long array?
    in C

    malloc for long long array?

    I'm a novice C programmer and am getting stuck on the insistence of malloc on using "size_t" for data array length. I want to use:
    Code:
    float *array
    long long int n
    array = malloc(n*sizeof(float))
    C insists on truncating my "long long int" to "size_t". So perhaps I have to redefine "size_t" or use an alternative to malloc. But how?
    See more | Go to post

  • kiser89
    started a topic malloc array of structs + a little more
    in C

    malloc array of structs + a little more

    I'm having a problem with my array of structs and segmentation faults. I have this struct that represents one line of a source file:
    Code:
    struct threeTokens {
    int lineNumber;
    char* cmd;
    char* param;
    }; line;
    This is the code that tries to fill the array of structs, which is a global variable called program:
    Code:
    program = malloc(numLines * sizeof(line));
            while(NULL != fgets(buffer, SIZE, fp)){
    ...
    See more | Go to post

  • Changing the size of an array passed to a function problem!

    Hi all,

    I have the following scenario:

    Code:
    int main()
    {
       char a[] = "Hello";
       printf("Modified string: %s\n", modify_str(a));
    }
    
    char *modify_str(char *b)
    {
       /* Insert a  '+'  after every letter in the string */
       /* "Hello" becomes "H+e+l+l+o+" */
       return b;
    }
    Now my...
    See more | Go to post
Working...