+ 1

C++

int a=4,b=2,c; int *p; p=&a; c=b*p; // -> c=? edited

25th Feb 2018, 3:39 AM
Nguyễn Văn Bảo
Nguyễn Văn Bảo - avatar
5 ответов
+ 5
to fix the compile error on line 4, try instead : b = *p; ( what you wrote b*=p is a multiplication between an int and a ptr, equivalent to b = b * p which fails. ) See sample code below: https://code.sololearn.com/cIeqM1m9UKNt/?ref=app
25th Feb 2018, 4:43 AM
ifl
ifl - avatar
+ 3
compilation error
25th Feb 2018, 3:56 AM
Chris
Chris - avatar
+ 1
This is just an idea, not a complete program should still have errors occur
25th Feb 2018, 5:14 AM
Nguyễn Văn Bảo
Nguyễn Văn Bảo - avatar
+ 1
you'll get a compilation error, because you intended to multiply an int type variable with a pointer that point to an int(int*)
25th Feb 2018, 6:32 AM
Rayhan Hamada
Rayhan Hamada - avatar