jeudi 3 août 2017

I used cin to get a string input as shown below in the code and it works fine. Is it alright?

#include<iostream>
#include<stdio>

using namespace std;

int main()
{   int n;
    char s[15];
    cin>>n;
    cin>>s;
    cout<<n*2<<"\n";
    cout<<s;
    return 0;
}

I tried with gets and fgets function but they don't work just after cin..

Aucun commentaire:

Enregistrer un commentaire