错误代码:

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的更多相关文章

  1. 问题:编译eshoponcontainers失败,提示error:invalid reference format

    环境: visual studio 2017 v15.4.2,docker ce Version 17.06.0-ce-win19 (12801) 参考问题页: https://github.com/ ...

  2. 关于 ReactNative 环境搭建之 error: invalid developer directory '/Library/Developer/CommandLineTools' - RN

    简要说明,此次尝试安装 ReactNative 时当前 MacPro 版本为 10.13.6.Xcode 版本为 Version 9.4.1 (9F2000),按照官方的完整原生环境搭建流程一步步执行 ...

  3. python安装locustio报错error: invalid command 'bdist_wheel'的解决方法

    locust--scalable user load testing tool writen in Python(是用python写的.规模化.可扩展的测试性能的工具) 安装locustio需要的环境 ...

  4. mysql5.7下的timestampn Error : Invalid default value for 'timestamp'

    表格创建是爆了个错 Error : Invalid default value for 'timestamp' 参考:http://www.jb51.net/article/71107.htm 这版本 ...

  5. 解决mac升级后,出现的 xcrun: error: invalid active developer path, missing xcrun 错误

    最近升级了mac系统,然后接着写代码就出问题了. 报错信息如下: xcrun: error: invalid active developer path (/Library/Developer/Com ...

  6. 关于在xml文件中的 error: invalid symbol: 'switch' 错误

    在xml布局文件中使用Switch控件时,出现error: invalid symbol: 'switch'报错,代码如下: <Switch android:id="@+id/swit ...

  7. Apache Error: Invalid command ‘Allow’, perhaps misspelled or defined by a module not included in the server configuration

    在一个Window Server 2008R2系统上使用Apache架设了一个PHP的网站项目 在配置Apache的过程中出现了以下问题   根据上面的提示说是没有相应的权限,那就在虚拟主机里进行了配 ...

  8. Python pip – error: invalid command ‘bdist_wheel’

    原文@http://software-engineer.gatsbylee.com/python-pip-error-invalid-command-bdist_wheel/ Python pip – ...

  9. 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 ...

随机推荐

  1. L - Non-Prime Factors (质数筛选+因子分解)

    In many programming competitions, we are asked to find (or count the number of) Prime Factors of an ...

  2. jacoco覆盖率工具测试及性能分析

    ant版本:https://ant.apache.org/bindownload.cgi jdk版本 注: ant 1.10    --->   jdk1.8 ant 1.9      ---& ...

  3. Linux压缩与解压缩文件

    1 将tgz文件解压到指定目录. tar zxvf test.tgz -C 指定目录 比如:将 test.tgz 解压到 /home目录:tar zxvf test.tgz -C /home 2 将指 ...

  4. javascript设计模式阅读后的感悟与总结

    单例模式 用于创建唯一的一个对象. 核心在于一个判断 var index if(index){ return index; } init(); 这样只会在第一次的时候初始化创建对象,以后都不会再创建对 ...

  5. LInux下几种定时器的比较和使用

    在数据通信过程中,会遇到对数据发送时间的格式要求.所以要在应用中根据实际要求选择不同的定时器,就要考虑到几种应用定时器的特点. 定时器文章参考 一般而言有, 1.sleep,usleep和nanosl ...

  6. 小程序swiper 滑块视图容器

    属性名 类型 默认值 说明 最低版本 indicator-dots Boolean false 是否显示面板指示点 indicator-color Color rgba(0, 0, 0, .3) 指示 ...

  7. win10下安装vs2013无法安装解决方案

    win10下安装vs2013无法安装解决方案 win+r,输入cmd进入命令行 进入界面后选择修复 进入vs_ultimate文件所在目录,输入: vs_ultimate /Uninstall    ...

  8. 生成git,ssh的key

    git clone ssh 代码: 报错: Warning: Permanently added 'gitee.com,120.55.226.24' (ECDSA) to the list of kn ...

  9. 7ci

  10. flask第一章 flask启动 路由视图 FlaskRequest jinja2 FlaskSession

    一.简单了解flask web框架 优点: 小而精,组件只有session,第三方机构强烈支持flask,极其简单 缺点: 由于第三方软件的关系,稳定性相对较差,flask-session 扩展知识: ...