I have started C tutorial.
The issue is with my code.
My aim is to take user’s input and then print the alphabet series. Printing the alphabet series from the point the user entered the input.
Here is the code.
#include<stdio.h>
int main() {
char alpha_U;
printf("Enter the letter from where you want in upper case: ");
scanf("%c", alpha_U);
for (char i = alpha_U; i <= 'Z'; i++) {
printf("%c", i);
}
return 0;
}
>Solution :
Your code is almost fine, except for
scanf("%c", alpha_U);
which requires a pointer as second argument.
I am not expert of C or C++ programming, so the thing I would suggest you is to checkout the documentation on cplusplus.com.
Specifically, here is how scanf is documented:
https://cplusplus.com/reference/cstdio/scanf/
The additional arguments should point to already allocated objects of the type specified by their corresponding format specifier within the format string.
so in your case you should be doing
scanf("%c", &alpha_U);