# Thread: Help! Warning: Initialization makes integer from pointer without a cast

1. ## Help! Warning: Initialization makes integer from pointer without a cast

I am writing a program and in line 50 it marks me this: Warning: Initialization makes integer from pointer without a cast. How do I fix it? The problem started when I had to create a loop to ask whether yes or no if the user would like to calculate another trip. I do not know how to fix. Please help.

Code:
```#include <stdio.h>

int main(void)

{

float numP, numL, HalfCost, EachLcost, TotalHalf, TotalCost, ans;
int loop;

printf("\nPlease enter the number of passengers. Children under the age 12 are represented by .5: ");

scanf("%f",&numP);

if (numP<0 )
numP=3;
else
printf ("%f",numP);

printf ("\nHow many legs the trip has to get to the destination?");
scanf("%f",&numL);
TotalHalf = 0;

loop=1;
while (loop <= numL){

printf("\nWhat is the price of leg %d?",loop);
scanf("%f",&EachLcost);
TotalHalf =TotalHalf + EachLcost;
loop++;
}
printf("\nThe total cost for half the trip is:");

if(TotalHalf>0)
printf("%f",TotalHalf);

TotalCost=TotalHalf*2;
printf("\nThe round trip cost for one person is: \$ %f",TotalCost);

printf("\nThe round trip cost for %f persons is: \$ %f",numP, TotalCost*numP);

printf("\nWould you like to calculate another trip cost? (Y/N)?");
scanf("%c",&ans);

if(ans == 'Y')
return main;

else(ans== 'N');
printf("\nThank You!");

}```

2. change ans to a char (it's a float now).

Right after the scanf("%c", &answ);

getchar();

to remove the newline char that scanf() leaves behind on the keyboard stream.
Code:
```if(ans == 'Y')
return main;```
is bad code - make it a loop, also (nested, with the one you have now).

Code:
```if(ans == 'Y')
return main;```
is bad code - make it a loop, also (nested, with the one you have now).
Hey, calling main.... always a good way to blow up the stack...

4. > return main;
This is a function pointer
What you're doing is returning the address of main, not calling main.
And since this is a pointer, and main expects to return an int, this is why you're getting a "integer from pointer" error message.

return main();
Now this would call main recursively, and as noted would be a bad thing to do.

If you want a loop, do this
Code:
```do {
// your code you want to repeat
} while ( ans == 'y' );```

5. Thank you all very much for all your help.