Thread: modf function incompatible pointer type

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    115

    modf function incompatible pointer type

    Hello

    I want to use the modf() fucntion to split the integral en fractional parts.
    But i dont know how i need to give the second parameter to the function.

    Code:
    int split(struct getallen *list, int **n, float **frac)
    {
    
    	int number, i;
    
    	struct getallen *kopy;
    
    	kopy = list;
    
    	while(kopy != NULL)
    	{
    		number++;
    		kopy = kopy -> next;
    	}
    
    	*n = (int *) malloc (number * sizeof(int));
    	*frac = (float *) malloc (number * sizeof(float));
    
    	kopy = list;
    
    	for (i = 0; i < number; i++)
    	{
    		*frac[i] =  modf(kopy -> getal, &n[i]);
    	}
    
    	return 0;
    	
    
    
    }

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    I found an example here

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    115
    Thank you, i have looked at examples. But i dont know how to putt it in my excersise because i have a double pointer that is an integer

  4. #4
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    First off, modf's 2nd argument is supposed to be a floating point data type: modf - C++ Reference

    Furthermore, in the context of your function, n[i] would provide the ith pointer in your series, and modf is looking for a pointer, so using the address symbol & is not necessary. But still, **n is an int and modf wants a floating point data type, so I suggest you either change **n or use a temporary variable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  2. Conversion of pointers to functions
    By hzmonte in forum C Programming
    Replies: 0
    Last Post: 01-20-2009, 01:56 AM
  3. Replies: 5
    Last Post: 08-12-2007, 05:26 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM