c语言将数据写入文件后乱码_C语言中写入文件的字符数组为乱码,但整形数据却正常!!!...
在TC中~#include#include#include#include#includecharstr[10];staticcharstr2[10]="1234";structstudent{intnum;char*name;longphone...
在TC中~
#include
#include
#include
#include
#include
char str[10];
static char str2[10]="1234";
struct student
{
int num;
char *name;
long phone;
char *homework;
};
student stu1;
void input()
{
FILE *fp;
if((fp=fopen("D:\\stu1.txt","at+"))==NULL)
{
printf("Cannot open file,strike any key exit!");
getch();
exit(1);
}
printf("please input the student's information:\n");
printf("input student's num:\n");
scanf("%d",&stu1.num);
if(stu1.num!=0)
{
printf("input student's name:\n");
scanf("%s",stu1.name);
printf("input student's phone:\n");
scanf("%ld",&stu1.phone);
printf("input student's homework:\n");
scanf("%s",stu1.homework);
fprintf(fp," %d\n %s\n %ld\n %s\n",stu1.num,stu1.name,stu1.phone,stu1.homework);
}
else
{
printf("the end of the input!\n");
}
fclose(fp);
getch();
}
void output()
{
printf("stu1 num:");
printf("%d\n",stu1.num);
printf("stu1 name:");
printf("%s\n",stu1.name);
printf("stu1 phone:");
printf("%ld\n",stu1.phone);
printf("stu1 homework:");
printf("%s\n",stu1.homework);
getch();
}
void view_key()
{
printf("the key is:");
printf("%s\n",str2);
getch();
}
void change_key()
{
printf("the old key is 1 2 3 4.\n");
printf("Now please enter the new key:\n");
scanf("%s",str2);
printf("Now the new key is:\n");
printf("%s\n",str2);
getch();
}
void main()
{
laber:;
printf("please enter key:\n");
scanf("%s",str);
if(strcmp(str,str2)==0)
{
printf("please enter key again:\n");
scanf("%s",str);
if(strcmp(str,"1234")==0)
{
printf("please enter key the last time:\n");
scanf("%s",str);
if(strcmp(str,"1234")==0)
{
printf(" welcome to this system >_
printf("_________________________________________\n");
}
else goto laber;
}
else goto laber;
}
else goto laber;
toutou:;
int key;
printf(" 1--------input student information\n");
printf(" 2--------output student information\n");
printf(" 3--------view the key for tnis systerm\n");
printf(" 4--------change the key for this systerm\n");
printf(" 5--------you can leave the systerm\n");
printf(" -------------please enter your desition\n");
scanf("%d",&key);
switch(key)
{
case 1:
printf("Now,you can input one student information:\n");
input();
break;
case 2:
printf("Now,you can output student information:\n");
output();
break;
case 3:
printf("Now,you can view the key for this systerm:\n");
view_key();
break;
case 4:
printf("Now,you can change the key for this systerm:\n");
change_key();
break;
case 5:
printf("Now,you can leave the systerm!");
goto loop;
default:
printf("your decision is wrong --!\n");
}
goto toutou;
loop:;
getch();
}
展开
c语言将数据写入文件后乱码_C语言中写入文件的字符数组为乱码,但整形数据却正常!!!...相关推荐
- c语言中字符串数组应用,C语言中字符变量字符串和字符数组应用.doc
C语言中字符变量字符串和字符数组应用 字符变量(type`char`?字符串(string)和字符数组(type`char`arrary)是C语言中非常重要的结构成分,也是应用编程中常发生混淆?导致错 ...
- qt先生成json文件后程序启动时读取json文件在一组数据模拟下正常,换一组数据就出现乱码
提要 程序编号后自己模拟的数据程序在生成和解析json时都正常,但是换了一组数据,生成的json文件中部分中文乱码,且出现json文件的格式被混乱的现象. 效果 上述出现的不正确的json文件,如下: ...
- 用c语言对文件的写入和保存,C++_C语言中对文件最基本的读取和写入函数,C语言read()函数:读文件函数( - phpStudy...
C语言中对文件最基本的读取和写入函数 C语言read()函数:读文件函数(由已打开的文件读取数据)头文件: #include 定义函数: ssize_t read(int fd, void * buf ...
- excel数据导入python后不对齐_Python处理Excel文件的实用姿势
真正的勇士,敢于直面银行卡上的余额,敢于正视磅秤上的数字. 表格数据是最常见的数据类型,Excel是日常办公中最常接触的文件. 上一章提过Python可以通过openpyxl模块处理Excel文件. ...
- R 语言怎么保存工作目录到当前路径_C语言探索之旅 | 第二部分第七课:文件读写...
内容简介 前言 文件的打开和关闭 读写文件的不同方法 在文件中移动 文件的重命名和删除 第二部分第八课预告 1. 前言 上一课 C语言探索之旅 | 第二部分第六课:创建你自己的变量类型 之后,我们来学 ...
- c语言程序设计数据输入的,1.2 C语言的发展与特点免费阅读_C语言程序设计教程免费全文_百度阅读...
3.2 数据的输入/输出 结构化程序设计过程中,确定输入数据是重要的步骤之一,在程序中如何实现数据的输入呢?C语言中数据及字符的输入.输出是由函数语句完成的,下面将介绍从标准输入设备--键盘上输入数据 ...
- 使用计算机管理文件教后反思,《管理计算机中的文件》教学反思
<管理计算机中的文件>教学反思 一眨眼,新学期已经过半了.现在,写一写我的<管理计算机中的文件>教学反思.这是第八周方老师来我校调研的一节课.作为学校信息技术学科的新老师,方老 ...
- python文件定位函数_C语言中文件定位函数总结
C语言中文件定位函数主要是:fseek, ftell, fsetpos, fgetpos. 先来讲前两个函数,这是最基本的定位函数: fseek函数:能把文件指针移动到文件任何位置,其原型是:int ...
- 使用计算机管理文件教后反思,《管理计算机中的文件》教学设计
课题名称:管理计算机中的文件 教学对象:七年级 课 时:1课时 教学目标: 1.知识与技能 (1)了解访问文件的"地址"或"路径"的表示方法: (2) 掌握图片 ...
- 【C语言】将文本中汉字读入字符数组输出乱码
输出中文字符乱码 今天从文件中将中文读入字符数组后输出发现其中文变成了乱码,,令人头大. 解决办法 将文本编码格式改成ANSI即可. 打开记事本->文件->另存为->更改编码格式-& ...
最新文章
- debug控制台内容消失 idea_IDEA 乱码问题(解决方案篇)
- HDU 2009 求数列的和
- MCMC笔记Metropilis-Hastings算法(MH算法)
- python处理时间和日期_使用Python处理日期和时间
- 楼市调控要“围堵”更要“疏通”
- 用Opengl实现骨骼系统
- js中时间戳与日期格式的相互转换
- NOIP2014洛谷P2296:寻找道路(bfs)
- 一个快速生成元素背景的 React 组件
- 不同网段Linux通过路由表,Linux服务器架设---《路由表配置,实现不同网段不同网卡之间的ping...
- Ubuntu禁用root登录
- Docker 多模块打包启动(kitty-generator)
- centos7搭建ELK Cluster集群日志分析平台(四):Fliebeat-简单测试
- 根据APK文件查看应用的MD5签名
- 项目质量监测(三)e2e test端到端测试——单元测试和端到端测试 e2e test工具-Cypress Nightwatch TeatCafe Codecov-测试结果可视化
- out在matlab中,在仿真模型中添加一个输出端口模块(Out模块),能够将结果输出到MATLAB工作空间中。...
- html边框双箭头,纯CSS如何绘制双箭头
- Maya模型制作心得
- running_mean和running_var
- python win32con_python win32 简单操作方法