Error In Argument To Unary
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack error invalid type argument of unary ‘*’ Overflow the company Business Learn more about hiring developers or posting ads with us Stack error invalid type argument of unary ‘*’ (have ‘double’) Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community
Error Invalid Type Argument Of Unary ‘*’ (have ‘int’)
of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up error: invalid type argument of ‘unary *’ (have ‘int’) up vote 20 down vote favorite 7 I
Error Invalid Type Argument Of Unary '*' (have 'int')
have a C Program: #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
In Argument To Unary C++
and policies of this site About Us Learn more about Stack Overflow invalid argument to unary operator the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation invalid argument to unary operator subset Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it http://stackoverflow.com/questions/5455866/error-invalid-type-argument-of-unary-have-int only takes a minute: Sign up Error with pointers. Invalid type argument of unary * up vote 0 down vote favorite #include "cdebug.h" #include "stdlib.h" int main() { char *cbloc = (char *)malloc(sizeof(char) * 40); memset(cbloc, 40, sizeof(char) * 40); DFORC(cbloc, 0, sizeof(char) * 40); system("PAUSE"); } Below is the header I wrote for debugging with pointers #ifndef _CDEBUG_H_ #define http://stackoverflow.com/questions/23773019/error-with-pointers-invalid-type-argument-of-unary _CDEBUG_H_ #include "stdio.h" int counter; //Debugging functions written by skrillac //constants #define NEWLN() printf("\n"); #define DFORC(ptr, offset, len) for (counter = offset; counter < len+offset; counter++)printf("'%c', ", *ptr[counter]); #define DFORI(ptr, offset, len) for (counter = offset; counter < len+offset; counter++)printf("'%i', ", *ptr[counter]); #define DFORV(ptr, offset, len) for (counter = offset; counter < len+offset; counter++)printf("%x, ", *ptr[counter]); #endif The error is happening somewhere in the DFORC() macro. I guess my question is where is that exactly and how would I fix it? c pointers memset share|improve this question asked May 21 '14 at 2:27 skrillac 13 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted cbloc is a pointer to characters, so in DFORC, ptr is also a pointer to characters. The statement: printf("'%c', ", *ptr[counter]); First uses ptr as an array, accessing element counter of that array. This returns a char (not a char *). You then try to dereference that char, which is doesn't make sense, hence the error. To fix this, change that statement to either of the following statements: printf("'%c'
Help Suggestions Send Feedback Answers Home All Categories Arts & Humanities Beauty & Style Business & Finance Cars & Transportation Computers & Internet Consumer Electronics Dining Out Education & Reference Entertainment & Music Environment Family & Relationships Food & Drink Games & Recreation Health Home & Garden Local Businesses https://answers.yahoo.com/question/index?qid=20130827094339AAWhQXW News & Events Pets Politics & Government Pregnancy & Parenting Science & Mathematics Social Science Society & Culture Sports Travel Yahoo Products International Argentina Australia Brazil Canada France Germany India Indonesia Italy Malaysia Mexico New Zealand Philippines Quebec Singapore Taiwan Hong Kong Spain Thailand UK & Ireland Vietnam Espanol About About Answers Community Guidelines Leaderboard Knowledge Partners Points & Levels Blog Safety Tips Computers error in & Internet Programming & Design Next "Error: In argument to unary !", please help me solve this error in C++? I'm working on a task and I am getting this error in this piece of code int readfromfile(){ ifstream NumberFile("NUMBER.txt"); if(NumberFile.is_open()){ int i; int arr[50]; for(i; !NumberFile.eof; i++){ NumberFile >> arr[i]; ... show more I'm working on a task and I am getting error invalid type this error in this piece of code int readfromfile(){ ifstream NumberFile("NUMBER.txt"); if(NumberFile.is_open()){ int i; int arr[50]; for(i; !NumberFile.eof; i++){ NumberFile >> arr[i]; cout << arr[i] << endl; } } It says the error is on the line of the for loop. It's driving me crazy as in another program I have the same line without errors. Is it to do with something elsewhere in the code? Thank you. Update: The I in the for loop has since been corrected to i = 0. But this has nothing to do with the error. Follow 2 answers 2 Report Abuse Are you sure you want to delete this answer? Yes No Sorry, something has gone wrong. Trending Now Enrique Iglesias Automotive parts Coleen Rooney Lionel Messi Psoriatic Arthritis Symptoms Free Credit Report Michelle Wie Scarlett Johansson Sgt Owen 2017 Cars Answers Best Answer: Try for (i = 0; !NumberFile.eof(); i++) { Have fun. Source(s): AnalProgrammer · 3 years ago 1 Thumbs up 0 Thumbs down Comment Add a comment Submit · just now Asker's rating Report Abuse Perhaps you need to add #include