Input of initial data through main ()

Hello guys,

I am a beginner in C++ and would like to know the right way to receive data on the main function?

Just an example, in Java would be:

1
2
3
public static void Main (String[] args){
      
}



Thanks!
1
2
3
4
int main(){

return 0;
}


^Would be correct. If main returns 0, that just means that the program ran successfully.
BlueLeaderOne,

thanks,

but I meant how can I do to receive data when executing the app.

Let`s say:

$./app input1 input2 input3

How can I do to read these inputs inside the code?

Thanks!
Last edited on
Here is a program that prints all the program arguments

1
2
3
4
5
6
7
8
9
#include <iostream>

int main(int argc, const char* argv[])
{
	for (int i = 0; i < argc; i++)
	{
		std::cout << argv[i] << std::endl;
	}
}
Peter87

Thanks a lot!
Topic archived. No new replies allowed.