今日bug:error: invalid array assignment
错误代码:
struct STUD
{
int ID;//学号
char name[];
float score;
}stud;
STUD SS[];
student.open("student.dat",ios::in|ios::binary);
if(!student)
{
cout<<"打开文件失败!"<<endl;
return ;
}
int j=;
student.read((char *)&stud,sizeof(stud));
while(!student.eof()){
SS[j].name=stud.name;//报错!
SS[j].ID=stud.ID;
SS[j].score=stud.score;
j++;
student.read((char *)&stud,sizeof(stud));
}
student.close();
这段代码的目的是从文件.dat中读取数据,存储到结构体数组对象SS[j]中,但是对SS[j].name赋值是报错,改成了strcpy(SS[j].name,stud.name)即可,这里若用等号需要重载运算符=。注意添加头文件#include<cstring>
今日bug:error: invalid array assignment的更多相关文章
- 问题:编译eshoponcontainers失败,提示error:invalid reference format
环境: visual studio 2017 v15.4.2,docker ce Version 17.06.0-ce-win19 (12801) 参考问题页: https://github.com/ ...
- 关于 ReactNative 环境搭建之 error: invalid developer directory '/Library/Developer/CommandLineTools' - RN
简要说明,此次尝试安装 ReactNative 时当前 MacPro 版本为 10.13.6.Xcode 版本为 Version 9.4.1 (9F2000),按照官方的完整原生环境搭建流程一步步执行 ...
- python安装locustio报错error: invalid command 'bdist_wheel'的解决方法
locust--scalable user load testing tool writen in Python(是用python写的.规模化.可扩展的测试性能的工具) 安装locustio需要的环境 ...
- mysql5.7下的timestampn Error : Invalid default value for 'timestamp'
表格创建是爆了个错 Error : Invalid default value for 'timestamp' 参考:http://www.jb51.net/article/71107.htm 这版本 ...
- 解决mac升级后,出现的 xcrun: error: invalid active developer path, missing xcrun 错误
最近升级了mac系统,然后接着写代码就出问题了. 报错信息如下: xcrun: error: invalid active developer path (/Library/Developer/Com ...
- 关于在xml文件中的 error: invalid symbol: 'switch' 错误
在xml布局文件中使用Switch控件时,出现error: invalid symbol: 'switch'报错,代码如下: <Switch android:id="@+id/swit ...
- Apache Error: Invalid command ‘Allow’, perhaps misspelled or defined by a module not included in the server configuration
在一个Window Server 2008R2系统上使用Apache架设了一个PHP的网站项目 在配置Apache的过程中出现了以下问题 根据上面的提示说是没有相应的权限,那就在虚拟主机里进行了配 ...
- Python pip – error: invalid command ‘bdist_wheel’
原文@http://software-engineer.gatsbylee.com/python-pip-error-invalid-command-bdist_wheel/ Python pip – ...
- nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
iwangzheng.com tty:[0] jobs:[0] cwd:[/opt/nginx/conf] 12:45 [root@a02.cmsapi]$ /usr/local/nginx/sbin ...
随机推荐
- git 拉取远程代码
git 拉取远程代码 || 利用vscode编辑器自带了git,可在ctrl+~打开控制台拉取代码,非常好用哦~在实际项目开发过程中,往往是已经存在远程项目了,我们定义的需求是只需要简单的操作git, ...
- WPF中定时器与进度条的配合使用
WPF中定时器使用的注意事项: WPF需要使用System.Windows.Threading.DispatcherTimer定时器,而不能使用System.Timers.Timer定时器.因为Sys ...
- [转] jquery作者John Resig编写的微模板引擎:JavaScript Micro-Templating
I've had a little utility that I've been kicking around for some time now that I've found to be quit ...
- 穿透dom触发事件
const elems = document.elementsFromPoint(e.pageX, e.pageY); const instance = elems.filter(elem => ...
- Excel中如何截取字符串中指定字符后的部分字符
1.如何给某列属性为时间整体加一个时间值: 场景一:假如我有一个excel中的某一列如下图所示,如何将该列的时间(用B代替整列)整体加一分钟呢?方法很简单,在空白单元格填写时间格式图中A所示 ...
- fflush 和 fsync 的区别
int fflush(FILE *stream);If stream points to an output stream or an update stream in which the most ...
- 服务器安装SSH服务:
强制关闭yum进程: rm -f /var/run/yum.pid 启动SSH: service sshd start 设置开机运行: chkconfig sshd on
- MFC界面分割以及挂载
MFC中文档与视图(二) Last Edit 2013/11/19 这篇主要是介绍一下怎么去分割视图. 视图的分割分为:动态分割,静态分割.所谓的静态分割是指软件一启动视图就分割完成,而动态分割是在 ...
- AI 帮助涂鸦
这个小工具挺有意思,可以在涂鸦的同时自动猜测你要画什么,并自动完成. https://quickdraw.withgoogle.com/
- Maximum Sum of Digits(CodeForces 1060B)
Description You are given a positive integer nn. Let S(x) be sum of digits in base 10 representation ...