How to label the first input of user as 1 ,second input 2, third input 3..etc by using ofstream append? Everytime when I used terminal to run it
./addcontact.cpp name1
./addcontact.cpp name2

so that inside dat file it will has number of sequence in front of new name?
e.g. in dat file

1 name1
2 name2
3 name3

int main(int argc, char* argv[])
	int i =0;
	vector <string> input;
	Contact addingname;
if (argc == 2)
	cout<<"Ok, contact "<<i+1<<" "<<<<" added "<<endl;
	string newname = input[i];
	int size= input[i].size();
	for(int j = 0; j<size; j++)
		if (isalpha(newname[j]))
void addname(string name)
  ofstream myfile(CONTACTS, ios::app);
  if (myfile.is_open());


I used these codes but they are not working? and gave me undesired output...any idea how to modify it?

First I would be really careful about calling a variable 'size'. It could definitely clash with other things.

Let me recommend that you add comments to the major portions of your code. This will not only help us read what is going on in your code, but I bet once you translate that code to English you will understand what is going wrong.

This question has already been answered. Start a new discussion instead.