How to simply convert a float to a string in c?
<pre><code>FILE * fPointer;
float amount = 3.1415;
fPointer =fopen("vending.txt","w");
fprintf(fPointer ,amount);
printf("The file has been created for the first time and we added the value %f" , amount);
fclose(fPointer);
</code></pre>

<p>I am trying to save a float number to a text file but when i try to run this code it triggers a compiling errors because the function fprintf expects the second parameter to be an array of characters so how can i convert my float to a string so i can pass it , i come from a c# background where something like .toString() is possible so is there any thing like that in c to directly cast a float to a string ? </p>