错误代码:

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. python 【pandas】账号、银行卡号、身份证号导出文件后以科学计数法显示问题解决

    问题描述:excel表中的一些数据会以文本格式格式保存,例如一些较长的编号.银行账号.身份证号等,再python中导出文件后,会发现数据以科学计数法显示,影响后续使用. data2_3.to_exce ...

  2. python 数据分类汇总

    STEP1: #读取数据: import pandas as pdinputfile_1 = "F:\\大论文实验\\数据处理\\贫困人口数据_2015.xlsx" data1 = ...

  3. python实现汉诺塔问题

    汉诺塔问题可以简单描述成为将a柱子上的圆盘按一定规则借助b柱子完美地复制到c柱子上.现假设有a,b,c三根柱子,a柱子上的圆盘从上到下依次标号为1,2,3,……,n,且为递增状态.规则:每次移动一个盘 ...

  4. vue中data中引用本地图片报错404

    首先说明vue-cli中assets和static两个文件的区别 1.assets在项目编译的过程中会被webpack处理理解为模块依赖,如果执行npm run dev或npm run build命令 ...

  5. vue2 作用域插槽slot-scope详解

    插槽分为单个插槽,具名插槽,还有作用域插槽,前两种比较简单这里就不赘述了,今天的重点是讨论作用域插槽. 简单来说,前两种插槽的内容和样式皆由父组件决定,也就是说显示什么内容和怎样显示都由父组件决定: ...

  6. 面试题3--数组中的重复数字(new数组的新写法)

    总是忘了一些条件的判断,比如非空或者其他之类. #include<iostream> using namespace std; int Frepeat(int num[],int leng ...

  7. git pull更新错误解决办法

    Your local changes to the following files would be overwritten by mergeerror: Your local changes to ...

  8. AngularJs在ng-click函数中获取代表当前元素的DOM对象

    html代码 <div ng-click="test($event)">111</div> Controllers.js $scope.test= func ...

  9. mpvue学习笔记(一) 基础介绍

    一. 小程序环境搭建 后台地址:https://mp.weixin.qq.com/ 文档地址:https://developers.weixin.qq.com/miniprogram/dev/ 注册账 ...

  10. 【Monkey】Monkey稳定性测试常用命令

    Monkey稳定性测试常用命令: 1.adb shell monkey n 2.adb shell monkey -p  com.android.calculator2 1000 3.adb shel ...