
excel
c#includestruct Person {int id;char name[10];char gender[3];};int mAIn(int argc, char *argv[]) {// 在程序所在目录下,会发现一个名为person.csv的文件FILE *file = fopen("person.csv", "w");struct Person people[] = {{1, "John", "Male"}, {2, "Jane", "Female"}, {3, "Bob", "Male"}};int peopleAmount = sizeof(people) / sizeof(struct Person);for (int i = 0; i < peopleAmount; i++) {fprintf(file, "%d,%s,%s", people[i].id, people[i].name, people[i].gender);}fclose(file);return 0;}这个示例程序展示了如何使用数组来存储个人信息,并将其写入到一个CSV文件。您还可以根据需要修改数组中的内容和格式来适应不同的需求。通过这种方式,您就可以将数据保存在CSV文件中,并随时打开和处理。Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号