主题:C++,请指教
[color=FF0000][size=3]声明:偶是个C++初学者,SO,很多问题可能问得很白痴,请见谅哈,希望大家指教,谢谢!!![/color][size=5]#include <iostream>[/size]
using namespace std;
int main()
{
unsigned int x;
unsigned int y=100;
unsigned int z=50;
x=y-z;
cout<<"Differernt is:"<<x;
x=z-y;
cout<<"\n"<<"Now different is:"<<x<<endl;
return 0;
}
这个程序运行结果是
Differernt is:50
Now different is:4294967246
我想问一下4294967246这个结果是怎么得到的,谢谢咯![/size]
还有一个程序:
#include <iostream>
using namespace std;
struct student
{ int num;
char name[20];
char sex;
int age;
};student s1;
void main()
{
s1.num=97001;
s1.name="Lin Lin";
s1.sex='F';
s1.age=19;
cout<<s1.num<<s1.name<<s1.sex<<s1.age;
}
出现错误的是:error C2440: '=' : cannot convert from 'char [8]' to 'char [20]'
There is no context in which this conversion is possible
Error executing cl.exe.
我看不懂是什么意思,要怎么改啊?
using namespace std;
int main()
{
unsigned int x;
unsigned int y=100;
unsigned int z=50;
x=y-z;
cout<<"Differernt is:"<<x;
x=z-y;
cout<<"\n"<<"Now different is:"<<x<<endl;
return 0;
}
这个程序运行结果是
Differernt is:50
Now different is:4294967246
我想问一下4294967246这个结果是怎么得到的,谢谢咯![/size]
还有一个程序:
#include <iostream>
using namespace std;
struct student
{ int num;
char name[20];
char sex;
int age;
};student s1;
void main()
{
s1.num=97001;
s1.name="Lin Lin";
s1.sex='F';
s1.age=19;
cout<<s1.num<<s1.name<<s1.sex<<s1.age;
}
出现错误的是:error C2440: '=' : cannot convert from 'char [8]' to 'char [20]'
There is no context in which this conversion is possible
Error executing cl.exe.
我看不懂是什么意思,要怎么改啊?