User Profile

Collapse

Profile Sidebar

Collapse
mprathap
mprathap
Last Activity: Apr 28 '07, 04:47 AM
Joined: Apr 27 '07
Location: PHL, US
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • mprathap
    replied to Segmentation Fault
    in C
    In that case, what is the differnce between

    Code:
    x = (struct vector *)malloc(sizeof(struct vector *))
    and

    Code:
    x = (struct vector *)malloc(sizeof(struct vector))
    i.e. under what circumstance would you want to allocate space corresponding to a pointer?
    See more | Go to post

    Leave a comment:


  • mprathap
    replied to Segmentation Fault
    in C
    Thanks for the reply budy. I fixed the problem. I was in Java for quite sometime and these subtle things in C are screwing me up grandly [:D]

    I have one more question:

    You said I should use x = (struct vector *)malloc(sizeof (struct vector));

    But should it not be x = (struct vector *)malloc(sizeof (struct vector *)) since x is a pointer.

    But both of them seem to work fine. So which one is...
    See more | Go to post

    Leave a comment:


  • mprathap
    started a topic Segmentation Fault
    in C

    Segmentation Fault

    Let me state my problem.

    This is my main.c

    Code:
    #include <stdio.h>
    #include "includes/first_order_local_matrix.h"
    
    int main()
    {
            float eps = 1;
    
            struct vector *x, *y, *rho, *q;
            struct matrix *P;
    
            initialize_vector(x,3);
            initialize_vector(y,3);
            initialize_vector(rho,3);
    ...
    See more | Go to post
No activity results to display
Show More
Working...