#include <iostream>
#include <fstream>
using namespace std;
int welcomeScreen(int &success) {
string keyContinue;
bool loop = true;
while(loop) {
cout << "Welcome, traveler! Press 'Q' to continue to the main menu." << endl;
cin >> keyContinue;
if (keyContinue == "q") {
success = 1;
break;
}
}
return success;
}
void mainMenu() {
int success;
int menuSelection;
bool loop;
if (success) {
cout << "MAIN MENU: \n" << endl;
cout << "1. Login \n2. Register" << endl;
while(loop) {
cin >> menuSelection;
switch(menuSelection) {
case 1 : cout << "login screen" << endl;
break;
case 2 : cout << "register screen" << endl;
break;
default : cout << "Please select an option from the menu..." << endl;
}
}
}
}
void exit() {
}
int main()
{
int success;
welcomeScreen(success);
if (success) {
mainMenu();
}
return 0;
}
当我输入'Q'时,程序显示'MAIN MENU'和2个选项,但在我选择一个选项之前返回0,我无法找出原因。我是学习C ++的新手,这可能是一种很难学习的方式,但我感谢大家的帮助。
答案 0 :(得分:0)
尝试var express = require('express');
var app = express();
var cheerio = require('cheerio');
var request = require('request');
var fs = require('fs');
app.listen(8080);
console.log('Running');
app.get('/', function(req, res) {
console.log('Recieved the get Request');
var i = 1;
var count = 0;
while (count < 10) {
var url = 'http://www.imdb.com/title/tt' + i + '/';
console.log(url);
count = count + 1;
i = i + 1;
request(url, function(error, response, html) {
if (!error) {
var $ = cheerio.load(html);
var title, ratings, released;
var json = {
title: '',
ratings: '',
released: ''
};
$('.title_wrapper').filter(function() {
var data = $(this);
json.title = data.children().first().text().trim();
json.released = data.children().last().children().last().text().trim();
});
$('.ratingValue').filter(function() {
var data = $(this);
json.ratings = parseFloat(data.text().trim());
});
console.log(json);
fs.appendFile('message.txt', JSON.stringify(json, null, 4) + '\n', function(err) {});
};
});
};
res.sendFile(__dirname + '/index.js');
});
或先尝试分配成功,然后再将其传递。你没有成功,但结果是
mainMenu (const int &passed)
你还有mainMenu的原型吗?试着写
sucess = 1
之前int mainMenu(const int& passed);