Heloo

The program does not go
I need 2 files should be taken from argv

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  #include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{
	if (argc != 3)
	{

		cout << "Nici un argument.Trebuie puse cateva argumente." << endl;

		exit(1);

	}

	else
	{

		cout << "Argumentele sunt:" << endl;

		for (int i = 0; i<argc; i++)

			cout << argv[i] << endl;

		cin.get();


		system("pause");

		return 0;

	}

}
?
looks fine to me but what do you mean by "I need 2 files should be taken from argv"?
I mean, at the moment you print all arg values so you should have them.
do not run
Do you get errors?

try adding a
system("pause");

before exit(1) in the first if-clause
Last edited on
Does anything get printed out?
Can you actually step through the code?
how to do you actually run this? what's the command line look like before you press enter to run?

Don't use exit, and don't use system. And remove the return on line 33: It's better just to return 0 on line 36. if you want to "pause", see here:
http://www.cplusplus.com/forum/beginner/1988/
Last edited on
Topic archived. No new replies allowed.