Saturday, July 23, 2016

istringstream Example in C++

#include<bits/stdc++.h>

using namespace std;

int main()
{
 string s;
 getline(cin,s);
 int a[10],n,i;
 n=0;
 
 istringstream p(s);
 
 while(p>>a[n]) n++;
 
 for(i=0; i<n; i++)
 {
  cout<<a[i]+5<<" ";
 }
 cout<<endl;
}

No comments:

Post a Comment

Thank you for commenting. Please wait for response :)