wulinsam 2015-01-12 14:28 采纳率: 0%
浏览 1632

关于string和char的程序,求解~?为什么运行不通过

#include
#include
#include
using namespace std;
const int MAXSIZE = 100;
typedef struct
{
string address;///??
int x;
string next;///????
}info;
typedef struct
{
info data[MAXSIZE];
int length;
}SeqList,*pSeqList;
pSeqList initSeqList()
{
pSeqList L = (pSeqList)malloc(sizeof(SeqList));
L->length = 0;
return L;
}
int main()
{
string first;
int len,cnt;
cin >> first >> len >> cnt;
pSeqList PL = initSeqList();
for (int i = 0;i < len;i++)
{
cin >> PL->data[i].address >> PL->data[i].x >> PL->data[i].next;
}
for (int i = 0;i < len;i++)
{
cout << PL->data[i].address << ends << PL->data[i].x << ends << PL->data[i].next << endl;
}
return 0;
}


测试数据:
00100 6 4
00000 4 99999
00100 1 12309
68237 6 -1
33218 3 00000
99999 5 68237
12309 2 33218

  • 写回答

6条回答 默认 最新

  • threenewbee 2015-01-12 14:34
    关注
     cin >> PL->data[i].address >> PL->data[i].x >> PL->data[i].next;
    

    这里PL是空的,根本没有分配空间

    评论

报告相同问题?

悬赏问题

  • ¥15 CCF-CSP 2023 第三题 解压缩(50%)
  • ¥30 comfyui openpose报错
  • ¥20 Wpf Datarid单元格闪烁效果的实现
  • ¥15 图像分割、图像边缘提取
  • ¥15 sqlserver执行存储过程报错
  • ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
  • ¥15 浮窗和全屏应用同时存在,全屏应用输入法无法弹出
  • ¥100 matlab2009 32位一直初始化
  • ¥15 Expected type 'str | PathLike[str]…… bytes' instead
  • ¥15 三极管电路求解,已知电阻电压和三级关放大倍数