[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] malloc ter sig underligt



Hov før søren, jeg har glemt at poste funktionen! Det må i undskylde.

/* Finder alle de naturlige tal som går op i tal og lægger dem i arrayet
  *p. Retunerer hvor mange pladser der er i *p 
*/

int find_numbers (int *p, int tal) {

int f,s; /* føst, sidst */

f = 1;
s = tal;

int i = 0;
while (f <= tal) {

if (s*f == tal) { /* kommatal bliver automatisk frasorteret da man
arbejder med int */
/* de naturlige tal kommer i f */

// printf("%i\n",f); /* afkommenter her for at se hvad tallene faktisk bliver */

i++;
p = (int *) realloc(p,sizeof(int[i])); 
p[i-1] = f; /* her burde tallene bliver lagt i RAM */

}

f = f + 1;
s = tal / f;

}
return i;

}


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *