Hello world,

for example, i have a function who calculate some values, i wish write these
values in a file, inside a funtcion .

I am trying to do this but shows an error.

For example 

....
#include<iostream>
#define Pi 3.141516
...
using namespace std;

FILE *f;//where must i define a variable FILE *f? here? or inside a
funtcion?

  //function
 void suma(int i)
   {
     f=fopen("data.txt", "w+"); /// is it necessary to write f as incomig
variable? if yes, how to do it?
     float s=0;
     for (int i ; i<10;i++)
       {
          ++s=Pi;
       } 
     fclose(f);
   }

//main program 

int main ()
  {
      ...
      suma(i);
     ...
   }

specifically  shows erros inside a function. I think is because the
function.

A question: how did you write data into a text file inside a function?

is my question clear?

Bye 
Miguel.
-- 
View this message in context: 
http://www.nabble.com/error-writing-data-in-a-file-inside-a-function-tp19975878p19975878.html
Sent from the C-prog mailing list archive at Nabble.com.

Reply via email to