Today, encountered in the C-disk subdirectory of the error in writing files, the most of their own experiments to solve. A little bit of a record.
The code is as follows:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Main ()
{
int data[35];
int n=35,temp;
for (int i=0;i<35;i++)
{
Data[i]=i;
}
Srand ((unsigned) time (NULL));
FILE *FP;
Fp=fopen ("C:\\Program Files (x86) \\Microsoft Visual studio\\myprojects\\2016.11.22\\random\\ data store. txt", "w");
for (int j=0;j<35;j++)
{
Temp=rand ()%n;
printf ("%4d", Data[temp]);
fprintf (FP, "%4d", Data[temp]);
if (temp+1!=n)
{
DATA[TEMP]=DATA[N-1];
}
n--;
}
Fclose (FP);
}
At the beginning, just put the file's address C:\Program files (x86) \microsoft Visual Studio\myprojects\2016.11.22\random Copy to fprintf (), But in the run time will be error, and finally in each in, the file before adding a \ can write the data in.