vidit_X 29 Junior Poster

I have another question. When I initialize x to 0123, x prints to the console as 83. Why is this?

When you prefix a number with 0, its treated as octal. I think now you can figure out why 83 is getting printed :)

vidit_X 29 Junior Poster

Instead of

cin>>str

Use

getline(cin,str);
vidit_X 29 Junior Poster
max = num[counter];
min = num[counter];

You are assigning values to max and min from an un-initialized variable and that is the problem. The reason its working with other lines is after the first iteration, the num array gets intialized with the values.

What you can try is .. get a number from the file in the outer for loop, store it in max and min, leave inner for loop as it is and it should work.

vidit_X 29 Junior Poster

In Student.h, function declaration of setStudent takes an integer array or integer pointer as argument.

void setStudent(string idIn, string fNameIn, string lNameIn,int scoreIn[]);

But while calling it on line 39 in your code or line 40 here ...

student[numOfStu].setStudent(id, fName, lName, score[SCORE]);

you are actually passing an integer in place of integer pointer, 4th argument.
You are specifying an index in the array, which passes the integer at that index.
Just pass the array without any index and it should work.

YingKang commented: Thanks vidit_x . The error msg is gone now :) +2
vidit_X 29 Junior Poster

cout<<"String";

The "String" should start and end on same line in the editor or you can extend it like ..

cout<<"Str"
<<"ing";

vidit_X 29 Junior Poster

First of all, you cant have array of strings in char array. You need to have a 2D char array or a 1D string array like this ..

char wordToBeGuessed[][10]={cat,dog,......};

where 10 is the maximum size of any word in the list.

Now, before asking user to input a word, choose a random word out of the list. You can use rand() for that ..

int i=rand() % X;

where X is the number of words in the list.

And you'll need to input a single character and then check whether that letter is in the selected word until either the number of tries end or word is guessed correctly.

vidit_X 29 Junior Poster
#include<iostream>
#include<fstream>
#include<string>

using namespace std;

int mv(const string&,const string&);

int main()
{
	string source, dest;

	cout<<"Enter FilePath, source -";
	cin>>source;
	cout<<"Enter FilePath, Destination -";
	cin>>dest;
	
	try{
		mv( source, dest );
	}catch( char er[] ) {
		cout<<er;
		return -1;
	}

	cin.get();
	return 0;
}

int mv(const string &a,const string &b)
{
	fstream				file1, file2;
	fstream::pos_type	        size;
	char                            *data;

	file1.open( a.c_str(), ios::in | ios::binary | ios::ate );
	file2.open( b.c_str(), ios::out | ios::binary );

	if( !file1.is_open() ) {
		throw "Error Opening File";
		return -1;
	}

	if( !file2.is_open() ) {
		throw "Error Writing File";
		return -1;
	}

	size=file1.tellg();                    //Get the size of file1
	data=new char[size];
	file1.seekg( ios::beg );             //Set the get pointer at ios::beg
	file1.read( data, size );              //read the file1
	file2.write( data, size );             //write the file2
	file1.close();                         //close file1
	file2.close();                         //close file2
	delete[] data;                         //free memory

	if( remove( a.c_str() ) ) {
		throw "Error Moving File";
		return -1;
	}

	return 0;
}

Hows the formatting now?
Any other suggestions or corrections are welcome.

Ancient Dragon commented: good formatting effort :) +26
vidit_X 29 Junior Poster

Do not initialize steps with command[++cmd], this will surely increment cmd before it even enters the switch statement. Just initialize the steps variable with any legal value. It will be better if you initialize steps before the loop as I said in previous post.

ohnomis commented: solver of declaring variables inside switch cases +1