新人已阵亡~~求助~C2059 语法错误:“using namespace” C2143 缺少; (在“<<”前面)
第五版C++primer plus10章最后一道习题的初阶版,参照10-5改了试了下,想改个字符串板的。。弄了一晚上完全不知道问题所在==
<header.h>
struct MStruct
{
char vendor[50];
};
class List
{
private:
MStruct list[5];
int count;
public:
List();
void push(char pu[]);
char* pop();
//void ifempty();
//void iffull();
};
<ex10-8.cpp>
#include<iostream>
#include"header.h"
#include<cstring>
List::List()
{
for (int i = 0;i < 5;++i)
strcpy_s(list[i].vendor, "a");
count =0;
}
void List::push(char pu[])
{
if (count >= 5)
{
std::cout << "the list is full";
}
else
{
strcpy_s(list[count].vendor, pu);
++count;
}
}
char* List::pop() //返回字符串(首地址)
{
if (count=0)
{
std::cout << "the list is empty";
}
else
{
return (list[count-1].vendor);
--count;
}
}
<main.cpp>
#include<iostream>
#include"header.h"
#include<cstring>
#include<cctype>
int main()
{
using namespace std;
List ex1;
char ch;
char arr[50];
cout <<"please enter A to add, P to pop, Q to quit";
while (cin>>ch&&toupper(ch) != 'Q')
{
while (cin.get() != '\n')
continue;
if (!isalpha(ch))
{
cout << '\a';
continue;
}
switch (ch)
{
case 'A':
case'a': cout << "enter arr";
cin.get(arr, 50);
while (cin.get() != '\n')
continue;
ex1.push(arr);
break;
case 'P':
case'p': strcpy_s(arr,ex1.pop());
cout << "pop ED: " << arr << endl;
break;
}
cout << "please enter A to add, P to pop, Q to quit";
}
cout << "bye~“;
}
第一次踏上论坛,若是错误低级自己没发现,大神勿喷
<header.h>
struct MStruct
{
char vendor[50];
};
class List
{
private:
MStruct list[5];
int count;
public:
List();
void push(char pu[]);
char* pop();
//void ifempty();
//void iffull();
};
<ex10-8.cpp>
#include<iostream>
#include"header.h"
#include<cstring>
List::List()
{
for (int i = 0;i < 5;++i)
strcpy_s(list[i].vendor, "a");
count =0;
}
void List::push(char pu[])
{
if (count >= 5)
{
std::cout << "the list is full";
}
else
{
strcpy_s(list[count].vendor, pu);
++count;
}
}
char* List::pop() //返回字符串(首地址)
{
if (count=0)
{
std::cout << "the list is empty";
}
else
{
return (list[count-1].vendor);
--count;
}
}
<main.cpp>
#include<iostream>
#include"header.h"
#include<cstring>
#include<cctype>
int main()
{
using namespace std;
List ex1;
char ch;
char arr[50];
cout <<"please enter A to add, P to pop, Q to quit";
while (cin>>ch&&toupper(ch) != 'Q')
{
while (cin.get() != '\n')
continue;
if (!isalpha(ch))
{
cout << '\a';
continue;
}
switch (ch)
{
case 'A':
case'a': cout << "enter arr";
cin.get(arr, 50);
while (cin.get() != '\n')
continue;
ex1.push(arr);
break;
case 'P':
case'p': strcpy_s(arr,ex1.pop());
cout << "pop ED: " << arr << endl;
break;
}
cout << "please enter A to add, P to pop, Q to quit";
}
cout << "bye~“;
}
第一次踏上论坛,若是错误低级自己没发现,大神勿喷

...全文
相关推荐
C语言命语法错误大全
14. error C2143: syntax error : missing ';' before ......该错误是由于在......之前缺少';'引起的。解决方法是检查语句是否缺少';'。
navicat连接mysql出现2059错误的解决方法
对于初学者,理解这些概念和操作可能会有些挑战,但通过查阅相关文档和教程,如“使用Navicat连接远程Linux MySQL数据库出现10061未知故障”等文章,可以获取更多帮助。
Navicat连接Mysql报2059错误的原因以及解决方法.docx
### Navicat连接Mysql报2059错误的原因及解决方法#### 一、问题背景在使用Navicat工具连接MySQL数据库时,部分用户可能会遇到错误代码2059的问题,具体表现为:“authentication
华为 ME60 V800R011C10 配置指南 - SMPTE-2059-2配置
【华为ME60 V800R011C10配置指南 - SMPTE-2059-2配置】SMPTE-2059-2协议是针对媒体和娱乐行业的标准,它定义了如何在通信网络中利用SMPTE-2059-2报文传递精确的时钟信息
华为 NE20E-S V800R011C10 配置指南 - SMPTE-2059-2配置
华为NE20E-S V800R011C10配置指南详细讲解了SMPTE-2059-2协议在综合资源路由器中的应用。SMPTE-2059-2是一种专为视频设备间通过IP网络进行精确时间同步设计的协议,它


新手乐园
