modf function incompatible pointer type

This is a discussion on modf function incompatible pointer type within the C Programming forums, part of the General Programming Boards category; Hello I want to use the modf() fucntion to split the integral en fractional parts. But i dont know how ...

  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,409
    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
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    949
    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, 03:25 AM
  2. Conversion of pointers to functions
    By hzmonte in forum C Programming
    Replies: 0
    Last Post: 01-20-2009, 12: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21