hallo,i am a university student and i am now staring to learn c++...i know quite a few things of java... here is a part of my code ifstream spammails[spam]; for(int i=0;i<spam;i++) ifstream spammails(spamnames); (spam is an int,spamnames[] is a string array) i receive the following error: variable-sized object 'spammails' may not be initialized what kind of initialialization do i have to make?give null values?
Your variable type is ifstream and so you should be initializing it with the values it can contain and that is input file stream.
well i am trying to initialize it with various input stream values e.g for(int i=0;i<spam;i++) ifstream spammails("something.txt"); (something.txt is a file in the same folder with the cpp file but i receive the same error) give me an example if you can....sorry and thanks in advance
Thats not the way of initializing it. Try referring to the document where you should find a good sample for ifstream.