I am having a code that says:
#include<stdio.h>
typedef struct string{
char *ch_ptr;
}str_t;
#define newdef(a,b) \
char a ## sumthing[b * sizeof(str_t)]; \
str_t *a = (str_t *)a ## sumthing
main(){
newdef(input,5);
/* some lines of code */
}
Optional changes to code:
#include<stdio.h>
typedef struct string{
char *ch_ptr;
}str_t;
#define newdef(a,b) \
char a ## sumthing[b * sizeof(str_t)]; \
str_t *var1 = (str_t *)a ## sumthing
main(){
newdef(input,5)="Hello";
printf("%s\n",input);
/* some lines of code */
}
Can anyone explain what this code segment means? Is input
in this code a string (hope not) or a variable? If a variable then why doesn't the compiler throw an undeclared variable error?