C Programming 201 file I/O outputting to csv file

preview_player
Показать описание
Register for free.
Рекомендации по теме
Комментарии
Автор

I gotta thank you for this video sir. The explanation was very concise and the example was simple enough that I could understand perfectly and easily everything you said. I didn't even know it was possible to write to csv files with C! I'll definitely use this for a project I'm working on rn. Appreciate it!

FranksCreativeCorner
Автор

Get video! Thank you.
Some small changes for Linux users are:


#include <stdio.h>
#include <stdlib.h> // for system ("clear"); call

int main (void) {
FILE *fp;
fp = fopen ("excelType.csv", "w");
int array[5]={1, 2, 3, 4, 5};
int i;

if (fp == NULL){
printf("\033[1;91m"); // set terminal text to bright red
printf("That file couldn't be opened for some reason\n");
printf("\033[0;40m"); // reset terminal colors to default
getchar(); // use getchar() instead of pause() for Windows
return 1;
}

fprintf(fp, "6, 7, 8, 9\n10, 11, 12, 13, \n");
for(i=0; i<5; i++){
fprintf(fp, "%d, \n", array[i]); // prints down a single column
}
fclose(fp);
fp = 0;
system ("clear"); // clear the terminal
printf("\033[1;92m"); // set terminal text to bright green
printf("The file excelType.csv was written successfully.\n");
printf("Press any key to continue.\n");
printf("\033[0;40m"); // reset terminal colors to default
getchar(); // use getchar() instead of pause() for Windows
return 0;
}

azvedicgurukul
Автор

I'm having trouble with the text color..
I think it's better to use contract color in some area

mnj
Автор

sir how to print output from specific row and coloum in file handling programs?

prajwalnagarajappa
Автор

Can you please make video on how to read from Excel file and then display on console?

ashwithbhatt
Автор

Sr, I have a question. Where do I place the cvs file to be opened? It's because Im getting errors running the code

Gabo_
Автор

Pls don't use dark mode for online streaming. The contrast is not that good better go with light mode.

tilakthummanapally
Автор

Sir...how to add another array in the next column

Rohitdas-ejsc