P
P
Philip Polikarenkov2016-10-19 15:21:04
C++ / C#
Philip Polikarenkov, 2016-10-19 15:21:04

Why does the code fail?

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <ctype.h>

int main()
{
    setlocale(LC_ALL,"Rus");
    char  a;
    scanf("%s",a);
    printf("%s",a);
    int num;
    num = atoi(a);
    printf("%d",num);
    return 0;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RapperOfGods, 2016-10-19
@Vilibb

the scanf function works with pointers, so you had to pass not "a" as a parameter, but an address pointing to "a", in other words, write: scanf("%s", &a)

M
Mirn, 2016-10-19
@Mirn

because the pointer "a" is not clear where it points, and you are not sure where else you are trying to organize input from the keyboard, and as a result you get it is not clear what.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question