C
C
Chemodan2282019-10-18 21:38:24
C++ / C#
Chemodan228, 2019-10-18 21:38:24

How to pass text through the command line in C?

Good afternoon, I came across a task in which you need to transfer text via the command line (I know that this is related to argc argv), please help me out !!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-10-18
@TopToster

https://en.cppreference.com/w/c/language/main_function

#include<stdio.h>
int main(int argc, char* argv[])
{
  if(argc > 0)
  {
    for(int i = 0; i != argc; ++i)
       printf("%s\n", argv[i]);
  }
}

argv[0] = program name, then arguments 1, 2, 3 ... , argc --> argv[1], argv[2], ... , argv[argc]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question