If I had a method
int main(int argc, char* argv[]) {
I am under the impression that calling arguments and receiving data through standard i
The difference is in how you access them.
Arguments are accessible through argv
. Standard input is accessible through the stdin
file descriptor.
case 1 - command line arguments:
int i;
for (i=1; i < argc; i++) {
printf("%s", argv[i]); // Prints "1 2 3 4"
}
case 2 - standard input:
char buffer[121];
while (scanf("%120s", buffer) == 1) {
printf("%s", buffer); // Prints "5 6 7 8"
}