Answer the question
In order to leave comments, you need to log in
What is the difference between declaring int* a and int *a in C?
The syntax is already so confusing, why such differences in the declaration, if the result is the same?
/* main.c */
#include "stdio.h"
int a = 10;
int b = 20;
int *a_ptr = &a;
int* b_ptr = &b;
int main (void)
{
printf("%d\n", *a_ptr); //10
printf("%d\n", *b_ptr); //20
return 0;
}
Answer the question
In order to leave comments, you need to log in
Nothing different. Whitespace characters can be placed anywhere where they do not break a keyword, identifier, or constant. All options below are completely equivalent:
int*a;
int* a;
int *a;
int * a;
int *a, *b; // нормально
int* a, b; // Ошибка: b кажется указателем, но на самом деле - число.
In C, as in most languages, spaces in code can be ignored. They are just one of the token separators. Moreover, some lexemes are separated without separators.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question