Thank you, in advance, for your time. I have written this bit of code for the Fibonacci sequence.
Code:
9 int size=0;
10 int fib[DWORD];
11
12 printf("Enter size: ");
13 scanf("%i", &size);
14 printHistogram(fib, size);
15 return 0;
16 }
17 void generateFibonacci(int array[],int size)
18
19 {
20 int r, i;
21
22 for(i=1;i<=size;i++)
23 {
24 asm volatile("mov $1, %%eax;"
25 "mov $0, %%edx;"
26 "1:add %%eax, %%edx;"
27 "xchg %%eax, %%edx;"
28 "loop 1b":"=d"(r):"c"(i):"%eax");
29 array[i]=r;
30 }
31 }
32
33 void printHistogram(int array[], int size)
34 {
35 int c,u;
36 generateFibonacci(array, size);
37 for(c=1;c<size;c++)
38 {
39 for(u=1;u<array[c];u++)
40 {
41 printf("*");
42 }
43 printf("\n");
44 }
45 }
I have tried quite few things and I am trying to change the prototype for generateFibonacci to... int* generateFibonacci(size). I have been trying to use calloc inside generateFibonacci and then declare a pointer in main that points at the address of the pointer that generateFibonacci returns. Would someone mind showing me how to do so? Thanks. -court