瑞星卡卡安全论坛

首页 » 技术交流区 » 系统软件 » 【求助】c++新手问题!
HYPERTEXT - 2007-4-4 8:46:00
#include "stdafx.h"
#include "stdio.h"
#include "string.h"
#include "iostream.h"

struct stu{
int sum;char name[10];
};

int main(int argc, char* argv[])
{
    stu student[10];
    student[10].name="quyouli";//编译出错,提示不能把8个字符放到10个字符的变量里...
    student[10].sum=12;
    cout<<student[10].name<<student[10].sum<<endl;
   
    return 0;
}

//请问怎么做才能让student[10].name被输入各种小于11长度的字符串?
HYPERTEXT - 2007-4-4 9:12:00
明白了,用strcpy函数就能搞定。
新的问题又有了:
请问left operand must be l-value
是什么意思?
storin - 2007-4-7 22:23:00
我怎么认为是越界问题呢 ?
stu student[10];
student[10].name这个引用是不是有问题,总共数组长度才10,你怎么能用student[10]呢
1
查看完整版本: 【求助】c++新手问题!