我需要在我的linux系统上编译代码。这是一段简单的代码,我不知道哪里出了问题:
我有这个代码,但我不能编译它:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string char1, char2, char3, char4, char5, char6;
cout<<"Hello this is your standard True and False quiz"<<endl;
cout<<
请看一下我的代码:
#include <iostream>
using std::cin; // I would like to make cin object available
using std::cout; // I would like to make cout object available in source code
using std::get; // I would like to make cin.get() available
using std::fail; // I would like to make cin.fail() available
我刚刚开始学习c++,这是我使用structs完成的第一段代码,但是当我运行它时,我会得到一个分段错误。我正在用g++在linux中编译它。谁能看到错误在哪里,我明白是什么导致了分割错误,但我看不出是什么导致了它。
所有的帮助都很感激。
#include <iostream>
using namespace std;
struct people
{
string forename;
string lastname;
int age;
};
int main()
{
int num_numbers; //ask the user how many numbers the sequ
我试图在linux机器上编译和执行C++中的简单代码。但是程序被卡在代码的中间。我找不到原因。
这是代码
#include <iostream>
using namespace std;
int n;
int product =1;
int counter =0;
int p;
int main()
{
//return 1;
cout << "How many numbers?" << endl;
cin >> n ;
cout << "Input the numbers &
我有两个档案:
1是main.cpp
#include<iostream>
using namespace std;
int min(int,int);
int abs(int);
int gcd(int,int);
const char *s = "Read Error!!";
int main()
{
cout << "Enter first Value: ";
int i;
cin >> i;
while(!cin)
{
cout << s << endl;
我写了一个程序,在这个程序中,我想从用户那里获取输入,如果按下了除'N‘或'n’以外的任何键,程序将显示"HELLO WORLD“作为输出,否则将显示”正在退出“消息并退出。下面的程序可以在Linux下运行,但不能在Dev-cpp窗口中运行。即使将cin.get()更改为getchar()也不起作用。程序不等待用户输入。
我也在cin.get()之前添加了system("pause"),但是当按下一个键时,它总是进入程序的其他部分。
#include <iostream>
#include <cstdlib>
using nam
enter是一个非常简单的程序,可以将一些值转换成任何特定的数据类型,其中浮动的转换值为3精度值,9精度值的转换值为2倍。这是我的密码:-
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a;
long b;
char c;
float d;
double e;
cin >> a >> b >> c >> d >> e;
cout <
我对C++比较陌生,但对编程不是很熟悉,我也不明白为什么在我的C++程序中使用with循环来解决这个非常奇怪的问题。
while (runUserInputLoop)
{
displayMenu();
cout << "Enter the number that corresponds with your choice from the menu: ";
getline(cin, menuLoopChoice);
if (menuLoopChoice == "1")
{
cout <&l
这是我们的任务,我不知道应该使用什么命令来设置搜索函数。它应该使用搜索函数来搜索员工ID编号。如果找到,则显示详细信息。否则,告诉用户没有找到记录。这些是用户输入的6条员工记录和相应的数据结构字段: a. ID,No . b. Name . c. Age . d.性别(M/F) e.地址f.工资。
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
struct Info {
string Id;
string Name;
string
这是我真正创建的除hello world之外的第一个程序。这段代码有400多行代码,我想了解一些新的函数以及其他一些可以帮助我改进代码和C++知识的东西。我想我应该一头扎进去自学,而不是从我的书"Teach yourself C++ in one hour a day on 6 edition“中学到。
我可以学习哪些新函数来改进我的代码?
// Runescape Mining Calculator
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int
我知道这很含糊,但我是C++的新手。
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
cout << "Hello and Welcome to the Test Calculator!\n";
signed char choice;
char resp;
cout << "Choose your prob
我对c++不是很有经验,而且我在编写一个学习字符串函数的程序时遇到了麻烦。我试过通过编写其他程序来单独测试这些功能来排除故障。
预期行为:它在“”之前确定一个名称,在后面确定一个整数。
演示行为:返回w/a空白名称和0。
我的平台是linux/x86。
//I included my essential libraries and declared
//used functions.
#include <iostream>
using std::cout;
using std::cin;
#include <string>
using std::string;
i
我试图在我的程序中添加一个"QUIT“函数,但是输入它不起作用。进入"QUIT“后,程序照常重新启动。我怎样才能改变这一点?我尝试过修复括号之类的东西,但到目前为止,完全没有效果。
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
int sa;
sa=2;
int sr;
sr=0;
if (sa != 0)
sa=1;
string answer;
while (sa ==
为什么我的计算器不能正常工作?视觉工作室只是问我是否想使用最后一个成功的构建。
我不能看一下用户的输入值是否为字符串吗?
这是我的密码:
#include <iostream>
using namespace std;
int main() {
int operation;
int a;
int b;
cout << "Choose an operation:\n";
cout << "+ = Addition\n";
cout << "- = Sub
下面的程序在输入(例如,Error )时在Mojave (AppleClang 10.0.1.10010046)上输出10cm (注意,在值和字符串输入之间没有空格)。相同的输入在Ubuntu16.04 (GNU 5.4.0) (输出:Working)下工作。
int main() {
double val {0.0};
string unit {" "};
cout << "Enter a double value followed by a unit (cm , m, in, ft) with or without a spac