473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

invalid type argument of `unary *'

What's wrong?here's the code




Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #define pi  3.141592;
  4.  
  5. int main(void)
  6. {
  7.  
  8. float radium,diameter,perimeter,area;
  9.  printf("please input radium:");
  10.  scanf("%f",&radium);
  11.  diameter =2.0*radium;
  12.  perimeter =2.0*radium*pi;
  13.  area=radium*pi*radium;
  14.  printf("the diameter:%f\n the perimeter:%f\nthe area%f\n",diameter,perimeter,area);
  15.  
  16.  
  17.  
  18.   system("PAUSE");    
  19.   return 0;
  20. }
Jun 28 '13 #1
1 28410
Banfa
9,065 Expert Mod 8TB
The problem is not with the * operator, it can be chained as it is at line 13 if all the operands are variables or constants.

The problem all the operands are not variables or constants because at line 3 you have put a semi-colon at the end of your definition of pi which means that after preprocessing line 13 looks like this
Expand|Select|Wrap|Line Numbers
  1. area=radium*3.141592;*radium;
  2.  
With the extra ; the second * forms part of a second expression and it only has 1 operand so it is treated as the unary dereference operator, this operator operates on pointers and radium is a float so you get the error

[i]error: invalid type argument of unary '*' (have 'float')/I]

Remove the ; from line 3
Jun 28 '13 #2

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

Similar topics

10
by: Matthias | last post by:
Hello, I thought one major advantage of using functors as e.g. sorting predicates over functions would be that I can do something like this: void foo() { class Predicate { public:
19
by: Lucas Machado | last post by:
i'm doing some Linux Kernel hacking for a course i'm currently taking. there is a pointer to a struct (struct example_struct *ex_ptr) in a .c that i want to access in a system call. i defined a...
2
by: newbie29 | last post by:
I get this error "invalid type argument of '->'". It occurs when: if (num_process->t_pid == -1) { .... } I have defined the struct num_process in the same file as where the above is...
4
by: bob | last post by:
I have little C experience and am concurrently trying to tackle C and LKM's (a little too ambitious maybe) anyway here is the problem I'm having with an example module I found. static int...
3
by: Suyash Upadhyay | last post by:
Hello all, I was writing a code regarding offset of structure elements. struct a { struct b { int i; float f; char ch; }x;
5
by: Sheldon | last post by:
Hi Everyone, I have defined a function: struct Transient arrFromHdfNode(HL_NodeList *nodelist, struct Transient retv); and in the code: struct Transient arrFromHdfNode(HL_NodeList...
2
by: Barry | last post by:
The problem brought by one earlier post from comp.lang.c++ http://groups.google.com/group/comp.lang.c++/browse_thread/thread/bf636c48b84957b/ I take part of the question and reproduce the code to...
7
by: mirandacascade | last post by:
The questions are toward the bottom of this post. Situation is this: 1) Access 97 2) Multi-user appplication 3) SQL Server 2000 4) Sporadically (i.e. less than 1% of the time) encounter the...
4
Siddarth777
by: Siddarth777 | last post by:
#include<stdio.h> main() { int *a=5; int **p=&a; fflush(stdin); printf("%u,%u,%d",p,*p,**p); } getting compiled perfectly but am getting
2
by: Stephanie Smith | last post by:
I always get this error message! Here's the code: #include <stdio.h> #include <stdlib.h> int main(void) { char *string; char length_string = 0; char buffer_for_string = 0;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.