C writing files✍️
ฝัง
- เผยแพร่เมื่อ 5 ต.ค. 2021
- C write append delete file tutorial example explained
#C #write #file
int main()
{
// WRITE/APPEND A FILE
FILE *pF = fopen("C:\\Users\\Cakow\\Desktop\\test.txt", "w");
fprintf(pF, "Spongebob Squarepants");
fclose(pF);
// DELETE A FILE
/*
if(remove("test.txt") == 0)
{
printf("That file was deleted successfully!");
}
else
{
printf("That file was NOT deleted!");
}
*/
return 0;
} - วิทยาศาสตร์และเทคโนโลยี
#include
int main()
{
// WRITE/APPEND A FILE
FILE *pF = fopen("C:\\Users\\Cakow\\Desktop\\test.txt", "w");
fprintf(pF, "Spongebob Squarepants");
fclose(pF);
// DELETE A FILE
/*
if(remove("test.txt") == 0)
{
printf("That file was deleted successfully!");
}
else
{
printf("That file was NOT deleted!");
}
*/
return 0;
}
The "Nuclear Launch Codes" had me ROFL
The most important functions explained in a nutshell, thanks!
Fortunately, I work with C# daily, but it's interesting to see how it all works with the ancestor :D
thanks for the tips! i got a 91/100 on my midterm from your tutorials :D
Super video bro 👍👍👍👍
Absolute W for wumbo bro, you are the best
You're awesome 🙂
hey bro do you have a video on accessing perifreal io data? like reading and writing memory addresses for pcie or serial ports? more so pcie addresses. making a pcie spi card.
tnx ma maaan❤
bro just saved my ass
Became a fellow bro.
W
Ur channel is so underated
- Has 700k subscribers
@@lucasc5622 still , in comparison to other channels
is 1,38M enough?
Why is it considered to be a good practice to assign NULL if declearing a pointer?
how can we write a PERSISTENT FILE ???? for example if we change something we can use it changed next time we run the program
Files are persistent, that’s the point of a file.
.txt files are persistent
remove("system.32") ;
if you want to destroy your computer
nah, i'd win
how to use abstract file path?
random'
Random
Here' s some code I wrote with this:
#include
#include
#include
#include
#include
#include
#include
int main(){
FILE *pHelloWorld = fopen("c:\\users\\squee\\desktop\\Helloworld.c", "w");
fprintf(pHelloWorld, "#include
int main(){
printf(\"Hello world!\");
}");
fclose(pHelloWorld);
printf("would you like to delete the \"Helloworld.c\" file? (Y|N)
");
char userInput[100];
fgets(userInput,100,stdin);
if(userInput[0] == 'Y' || userInput[0] == 'y'){
if(remove("c:\\users\\squee\\desktop\\Helloworld.c") == 0){
printf("This file was deleted successfully!");
}
else{
printf("ERROR: file could not be found.");
}
}
else{
printf("File was not deleted.");
}
}
bro my file was not deleted ,have a look buddie :
#include
int main()
{
/*FILE *pF = fopen("test.txt","a");
fprintf(pF,"
spongebob squarepants");
fclose(pF); */
if(remove("text.txt")== 0)
{
printf("file deleted sucessfully");
}
else
{
printf("file was not deleted");
}
return 0;
}
Probably because the file needs to actually exist in order for it to be deleted and the code that creates the file is set as a comment in your code.