如果我写
int main()
{
int a[100] = {1,2,3,4,};
cout<<sizeof(a)/sizeof(a[0])<<endl; //a is a pointer to the first elem of array,
//isn't it
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到400!
如果我写
void func(int*a);
int main()
{
int a[100] = {1,2,3,4,};
func(a);
return 0;
}
void func(int *a)
{
cout<<sizeof(a)/sizeof(a[0])<<endl; //a is a pointer to the first elem of array
}
Run Code Online (Sandbox Code Playgroud)
然后我得到1!
那么为什么函数不知道数组大小呢?
class anurag
{
private:
int rollno;
char name[50];
int marks;
float percen;
void percentage(int num)
{
percen=(num/500)*100;
}
public:
void getdata(void)
{
cout<<"\n\nEnter the name of the student:";
gets(name);
cout<<"\n\nEnter the roll no: and the marks:";
cin>>rollno>>marks;
percentage(marks);
}
void display(void)
{
cout<<"\n\nThe name of the student is:";
cout.write(name,50);
cout<<"\n\nThe roll no: of the student is:";
cout<<rollno;
cout<<"\n\n The marks obtained is:"<<marks;
cout<<"\n\nThe percentage is:"<<percen;
}};
void main()
{
clrscr();
anurag F;
F.getdata();
F.display();
getch();
}
Run Code Online (Sandbox Code Playgroud)
为什么以下代码没有提供所需的输出?
myPreciousFunction(std::string s1 = "", std::string s2 = "")
{
}
int main()
{
myPreciousFunction();
}
Run Code Online (Sandbox Code Playgroud)
我能让这些论点看起来更漂亮吗?如果没有提供参数,我希望有空字符串.
如何将fillText()生成的文本倾斜为HTML5中的canvas标签?
它会以与MozTransform,webkitTransform,oTransform,transform等相同的方式完成吗?
我刚刚开始学习Java编程的基础知识.使用一本名为"为邪恶的天才编程视频游戏"的书.
我有一个非法的表达式错误开始错误,我不能为我的生活摆脱.我已经检查了书中的示例代码,我的相同.
错误来自for(int i = difficulty; i> = 0; i- - )行.
感谢您帮助新手.
import javax.swing.*;
public class S1P4
{public static void main(String[] args) throws Exception {
int difficulty;
difficulty = Integer.parseInt(JOptionPane.showInputDialog("How good are you?\n"+
"1 = Great\n"+"10 = Terrible"));
boolean cont = false;
do
{
cont = false;
double num1 = (int)(Math.round(Math.random()*10));
double num2;
do
{
num2 = (int)(Math.round(Math.random()*10));
}
while(num2==0.0);
int sign = (int)(Math.round(Math.random()*3));
double answer;
System.out.println("\n\n*****");
if(sign==0)
{
System.out.println(num1+" times "+num2);
answer = num1*num2;
}
else …Run Code Online (Sandbox Code Playgroud) 为了不阻塞反应器,我想异步读取文件,但我发现使用EventMachine没有明显的方法.我尝试了几种不同的方法,但没有一种感觉正确:
EM.popen('cat some/file', FileReader)感觉真的很奇怪,但比上面的替代品更好.与LineAndTextProtocol它结合使用它可以很快地读取线条.EM.attach,但我还没有找到任何如何使用它的例子,我在邮件列表上发现的唯一一件事就是它被弃用了...EM.watch,我没有找到如何用于阅读文件的例子.如何读取EventMachine反应器循环中的文件?
我需要在c#中显示节点图并找到可能的短路径(图10中的http://msdn.microsoft.com/en-us/library/aa289152(VS.71).aspx).我可以用什么API来绘制所有节点和链接?有人可以提供建议吗?
我想在pyqt中为列表添加标题和索引,简而言之,QT(qlistwidget,qlistview,qtablewidget,qtreeview)的列表真的不重要
..我想要像pyqt演示中的旋转框委托示例. .而不是列标题中的索引我想要一个字符串...
希望这个想法能够
提前明确