一个。读取单个字符并将其打印到标准输入。
湾对标准输入使用以下函数。函数是 bool.getCharacter(char* c).
Here's what I've done so far
#include <iostream>
#include <cstdio>
#define LENGTH 101
int main(void) {
#include <iostream>
using std::cin;
using std::cout;
int main() {
char c;
bool getCharacter(char* c) {
std::cout << &a << " " << a << std::endl;
while(std::cin >> *c) {
if(cin >> *c) {
cout << true << endl;
return 0;
}
else {
cout << false << endl;
return c;
}
return EXIT_SUCCESS;
}
第 11 行错误:此处不允许在“{”标记之前定义函数
答案 0 :(得分:0)
好吧,我不会解决你所有的问题,但让我们从这个开始,看看你是否能更进一步。
#include <iostream>
#include <cstdio>
#define LENGTH 101
using std::cin;
using std::cout;
bool getCharacter(char* c) {
std::cout << &a << " " << a << std::endl;
if (std::cin >> *c) {
return true;
}
return false;
}
int main(int, char **) {
char c;
while (getCharacter(&c)) {
cout << c << endl;
}
}
基本上,您尝试了嵌套方法,这确实是不允许的。你的 getCharacter() 方法做得太多了。它应该得到一个字符,而不是做任何其他事情,然后你必须实际调用它。