How to run C functions in a shell?

While learning C, I found out that you can see a guide to its functions in the linux shell (I used BASH). For instance:

man strlen man crypt man printf 

I would suggest that perhaps I could use these functions in shell scripts.

It's true? How to use these functions in a shell script?

+5
source share
2 answers

You can not. Manpages is a relic of a time when there was no IDE and no web pages for finding things. You must write your code in an editor such as ed or vim or emacs , look for functions with man , compile with cc . The fact that the man command searches for C functions does not mean that you can use these functions directly in the shell.

However, some of these functions also have an equivalent in * NIX: man 3 printf is a C function, but man 1 printf is * NIX.

+3
source

Short answer: you cannot use functions from the C library directly in the shell.

Look at the different manual pages that you get with the following commands:

 man 1 printf man 3 printf 

The first is from section 1 (user commands), and the second is from section 3 (C library). Although they serve a similar purpose, they do not match. You can use printf , described in section 1, directly in the shell. Browse man 7 man for a list of different sections.

+2
source

All Articles