#include <iostream>
using namespace std;
int main()
{
string message;
cout << "Ahlan ya user ya habibi." <<endl;
cout <<"what do you like to do today?" <<endl;
cout <<"please enter the message:" <<endl;
getline(c
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;
class base {
public:
int lookup(char c);
}; // class base
int base::lookup(char c)
{
cout << c << endl;
} // base::lookup
int main() {
base b;
char c
# include <iostream>
# include <string.h>
using namespace std;
int main()
{
int a=10;
int b=20;
char op[10];
const char p='+';
cout<<"enter the operation"<<endl;
cin>>op;
if(!strcmp(op,p)==0)
{
cout<<a+b;
}
请帮助理解我的简单C++代码有什么问题
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
string s = "qwertyuiopasdfghjklzxcvbnm";
string match = "w";
int n = s.length();
char char_array[n + 1];
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main() {
int numberArray[] = {};
int atoi(const char * str); // this fuction is used to convert the data into int
char line[10]; // this is a char array
我在C++里尝试不同的演员。在我对reinterpret_cast的理解中,它将不类型转换为根本不同的类型。但是下面的代码会抛出这个错误“从'char*‘到'int’失去精确的-fpermissive”。
#include <iostream>
#include <typeinfo>
using namespace std;
int main()
{
int i;
char *p = "This is a string";
i = reinterpret_cast<int>(p);
cout
两个月前,我在大学开始学习C++,我正在设法将动态2d数组(指向指针的指针)作为输入参数传递给函数。我有一个动态的2d数组:
int **p;
p = new int*[R];
for(i=0; i<R; i++)
p[i] = new int[C];
现在,我想使用const将这个指针p作为输入参数传递给一个函数。我的意思是,我希望函数不能修改矩阵的元素。
我试过这样做:
void func(const int **p) {
}
但我知道这个错误:
main.cpp:19:11:错误:从'int**‘到'const **’-fpermissive的转换无效
m
我对strcmp有点问题。
这是我的代码。
while (strcmp("m",wood) !=0 || strcmp("j",wood) !=0 || strcmp("o",wood) !=0){
cout << "(m for mahogany, o for oak, or p for pine): ";
cin >> wood;
}
这是我的错误:
dining.cpp: In member function ‘void DiningSet::woodType()’:
dining.cpp:7