Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

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.
...