By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,530 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,530 IT Pros & Developers. It's quick & easy.

How To Fix A Illegal Use Pointer ?

P: 2
#include<iostream.h>
int main()
{
char *nama_siswa;
int nilai_1;
int nilai_2;
int rata_rata;
char *phi;
int r;
int luas;

nama_siswa="Andi";
nilai_1= 84;
nilai_2= 88;
rata_rata= 86;
phi="3,14";
r=14;
luas=phi*r*r;

cout<<"Nama Siswa = ";
cout<<nama_siswa;
cout<<endl;
cout<<"Nilai 1 = ";
cout<<nilai_1;
cout<<endl;
cout<<"Nilai 2 = ";
cout<<nilai_2;
cout<<endl;
cout<<"Rata-Rata = ";
cout<<rata_rata;
cout<<endl;
cout<<endl;
cout<<"Phi = ";
cout<<phi;
cout<<endl;
cout<<"R = ";
cout<<r;
cout<<endl;
cout<<"Luas = ";
cout<<luas;
cout<<endl;
}
Sep 27 '15 #1
Share this Question
Share on Google+
2 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
This code:

Expand|Select|Wrap|Line Numbers
  1. luas=phi*r*r;
  2.  
phi is a pointer r is an int. A pointer times an int is what? a pointer? an int? The compiler won't guess.

Here's my guess but I could be wrong since I haven't examined the code in detail.
Expand|Select|Wrap|Line Numbers
  1. luas =(* phi)*r*r;
Sep 27 '15 #2

P: 16
You are absolutely right Sir!
Sep 29 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.