None from a semantical & syntactical point of view.
you mean char (*getInput)(); Without the brackets you'd have a function that returned a pointer to a char. With brackets getInput is a pointer to function which returns char.
No difference it all. Note that all the following declarations are the same:
char*getInput();
char* getInput();
char *getInput();
char * getInput();
char* getInput ();
char *getInput ();
char * getInput ();
char* getInput ( );
char *getInput ( );
char * getInput ( );
char* getInput ( ) ;
char *getInput ( ) ;
char * getInput ( ) ;
All of them let the compiler know there is a function named getInput
that returns a char *
and gets passed a specific, but unspecified, number of arguments of specific, but unspecified, types.
Edit
The space character in source files is mostly ignored and redundant.
for (n = 0; n < 1000; n++) { /* ... */ }
for(n=0;n<1000;n++){/*...*/}
It only matters inside strings and when it is needed to separate tokens that can't be separated by other means.
return 9; /* statement that returns from a function */
return9; /* statement that evaluates a variable */
No difference at all in terms of meaning. In fact, none even in terms of syntax. As long as the whitespace is somewhere, there's no problem. Both compile to precisely the same code.
It is often a matter of preference which is used. The traditional C coders generally prefer the second, as it is more indicative that the type is still char
, regardless of the fact it's a pointer. Many C++ coders, as I believe Bjarne Stroustrup himself has pointed out, prefer the char*
syntax because it is considered more in the OOP style. I personally prefer this one too, as it signifies that the variable is a char pointer.
Edit: Can't find where he actually wrote that, but you can see quite plainly in his BC++ Style and Technique FAQ guide that he prefers the char*
style syntax.
There is no difference.
int* a;
int *b;
int * c;
There is no different between a, b or c there either. They're both pointers. It's just you can put as many spaces in as you like.
HOWEVER, There is a difference between these:
int* a, a1, a2;
int *b, b1, b2;
int *c, *c1, *c2;
only on lnie C have you declared 3 pointers-to-ints. A and B both have one poitner-to-int and two ints.
To the compiler, there is no difference.
To my brain, the first form is preferred because it shows that the function returns a pointer-to-char (and not a char) more clearly. Of course, that is strictly IMHO.
I know i am answering what all have said...Just want to add a few more things :
What u possibly wanted to ask might be : char* getInput(); char (*getInput)();
Over here the first one represents : getInput is a function which returns pointer to a char. second is : getInput is a pointer to a function which returns a char.
In case of complicated declarations always remember!!! START READING FROM INSIDE THE BRACKETS
Consider this : char* (*getInput)(); Here, getInput is a pointer to a function which returns a pointer to a char.