Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - I think I save the array generated by C language in a file, how to separate each data with spaces?
I think I save the array generated by C language in a file, how to separate each data with spaces?
# contains "stdio.h"

# contains "string.h"

void log(int data[],int);

# contains "stdio.h"

# contains "string.h"

void mlog(int data[],int);

int main(){

int data[ 10]={ 1,2,3,4,5,6,7,8,9, 10 };

Mlog (data,10);

Returns 0;

}

void mlog(int data[],int data_size){

FILE * fp

int I = 0;

char tmp[20];

if((fp=fopen("data.txt "," a+"))! =NULL){

for(I = 0; I & ltdata _ sizei++)

{

sprintf(tmp," %d ",data[I]);

fputs(tmp,FP);

}

fclose(FP);

} Otherwise {

Printf ("Unable to open log file");

}

}