-
You use the variable path as the absolute path of the file, and you have to change its value every time, and the location of your file remains the same, so of course you can't read the file.
You need to keep it in sync, that is, if the value of the path changes, you need to rename the file at the same time, and rename the file with the rename() function, the function prototype:
int rename(char *lpoldname,char *lpnewname);
The first parameter is the original name of the file, and the second parameter is the name of the renamed file, if the rename is successful, it will return 1, otherwise it will return 0. Header file or.
There is also a mistake in saying that your ** above, char path[20]="c:\\";You forgot about the escape characters.
And you should start assigning from path[3], because"c:\\"There are only 3 characters minus a null character, and the subscript starts at 0 ( is a character).
-
Hope mine is helpful to you! Search all txt, then save it in a variable or keep it directly on the hard disk, then determine the number of txt files, and then use the number of txt files from 1 to the number of txt files as a random range.
-
List all the files, number them, and choose a serial number with a random number.
-
The C programming language is very powerful, and it is possible to open the corresponding text by opening the function of the text (the parameters in it indicate the location and file name of the text to be opened).
First, the header file included:
file *file = fopen("c:\\","r");The file name represents the C drive, the file name is R, which indicates that it is opened in read-only mode, and the second parameter indicates the opening method, A"Indicates that the append mode is open, r"Indicates that it is opened in read mode, w"Indicates that the data is opened in writing mode, and thirdly, the data is read into the text file
Method: char s[10] ="";
while (!feof(file))
fread(s,1,1,file);
Read and write open files through the fread function, which is how to change the contents of the file.
-
#include ""
int main()
Read data until the end of the file, read a data and output a data fclose(fp); Close the file return 0;
Debugging is correct. If you want to save the data to a[i], just change it, int i=0, a[100];
Just assign the value of the above variable ch to the array.
a[i++]=ch;
-
1. Get the list of disk files, and store n file path names in array[n];
2. Generate a random value i between 0 n, and access array[i] is sufficient;
-
Read the problem out loud and save it in an array.
Then use srand() and rand() to get a random number.
First, divide the random number by 9 to get the remainder. Get a random number within 10 to get the first question.
array. Then divide the random number by 9 to get the remainder. Get a random number within 10, that is, get the second problem, judge whether there is a problem in the array, and then take it again if there is no problem.
It's a bit complicated to do, and that's all I can think of.
The rookie one, seeing and laughing.
-
This is done with the rand srand function, whose header file is include
Each of the ten questions you have stored in the struct array, and then the position of the array is saved.
-
file *pfileopen = fopen("Pathname","r");r is read, w is write, and a is append. Specifically, look at the parameters of the function.
while( !feof(pfileopen) )
-
1. Get the list of disk files, and store n file path names in array[n]; 2. Generate a random value i between 0 n, and access array[i] is sufficient; ~
-
First of all, it has nothing to do with C, that's how any program handles it. If your information is one line a day, it's still simple, if not, then you guarantee the correctness of the data in the data, so that you can judge. 123456789 Green Tea Drink 12 87548796 Snow Cake 45879854123658 Biscuit 77 If that's the case, you just need to parse one line at a time, and the analysis inside a line uses a space to split the end of a property.
If they are one line, then you can only read each attribute by dividing the space, and if you read 3 attributes, then you will enter the attribute of another product. If there will be spaces in the product name, then you can also judge by the way whether the read attribute is a general character, or belongs to a pure number, if it is not a pure number, then the attribute still belongs to the product name, and can be merged.
-
This is the disadvantage of the simple C language, and it is inconvenient to read the information strings of different lengths in the file. In fact, you can consider setting a fixed length, and if there are insufficient places, add spaces, which will be more convenient to deal with. be lucky!
The drop-down box contains multiple items, and the text that can read one of the items in the drop-down box (n represents the index). >>>More
<>2. After entering the homepage of the format factory, you can see that there are many format conversions in it, and select audio to modify the song format. >>>More
Computer Level 2C language question types and scoring criteria: 1. Multiple choice questions: 40 questions, 1 point for each question. Points are given according to the standard answers. >>>More
int a,b,c;
scanf("%d%d",&a,&b);Enter a, bc=a+b; Add the two numbers to c >>>More
In C, all preprocessing commands start with a " " sign.
The concept of preprocessing in C programming: processing before compilation. There are three main aspects of preprocessing in C: macro definition and failing. >>>More