samedi 4 avril 2015

Error while taking array of strings as input

I am trying to take array of string as a input but its giving run time error



#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main()
{
string str[500];
int n;
cin>>n;
for(int i=0;i<n;i++)
scanf("%s",&str[i]); \\works fine with cin but gives error using scanf
return 0;
}




Process terminated with status -1073741510 (0 minute(s), 10 second(s))



works fine with cin but give error if i use scanf



Can some one tell me why its giving such error



what does that error mean and why doesn't it gives error while using cin




I am using code blocks 13.12



Aucun commentaire:

Enregistrer un commentaire