what is the problem with this code?

0 votes
asked Mar 1, 2018 by anonymous

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    char str[36];
    cin>>str[36];
    int x= strlen(str);
    cout<<x;
    return 0;
}

INPUT ::qwerty

OUTPUT ::3

2 Answers

0 votes
answered Mar 1, 2018 by anonymous

Problem is with "cin>>str[36];"
It should be "cin>>str;"

0 votes
answered Mar 9, 2018 by Fine Laurence Nizeyimana (140 points)
it should be like this

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    char str[36];
    cin>>str;
    int x= strlen(str);
    cout<<x;
    return 0;
}
commented Mar 9, 2018 by anonymous
thank u very much.........
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...