I tried to convert it like this:
#include <stdio.h> #include <stdlib.h> #define A 15 int main(){ return strtol(A); } But without result. How to convert a constant type (without printf)?
I tried to convert it like this:
#include <stdio.h> #include <stdlib.h> #define A 15 int main(){ return strtol(A); } But without result. How to convert a constant type (without printf)?
You have already been answered: #define does not create any constants! This is just a text substitution. It was:
#define A 15 puts(A); It will become just before compilation:
#define A 15 puts(15); As for strtol , do not be lazy to look into the man (or what you replace it with):
long int strtol(const char *nptr, char **endptr, int base); This function does not suit you: it translates the string into a number, and not vice versa (in that answer I was sealed, and you thoughtlessly copied the answer into the brain, without even trying to understand what it was about). You do not need to "convert the constant type" (sounds in this context as an abracadabra), but convert the number 15 to the string "15" , and now it should be output.
Well, in general, read some textbook on C. Because judging by the questions, you do not know the very basics, and without them you can poke at random for a long time.
Source: https://ru.stackoverflow.com/questions/533718/
All Articles