Query methods, classes and attributes in C language

Posted on

Question :

I wanted to know if in C language and possible query available libraries its classes modules and attributes like in the Python language that there are methods dir() and help() I’m beginning to learn C and I’m kind of lost. I’ll cite an example.

I import the stdio.h library to work with incoming and outgoing input data, but I do not know the modules, variables, or classes that the library has. Is there any way to help me at the time of development?

#include <stdio.h>

int main()
  printf("C da depressão :(n");
  return 0;


Answer :

C only have functions, constants, defined types, macros and global variables (albeit rare, because it is inadvisable). One way to find the information is to look at the header ( .h ) files where you have the declarations.

I do not advise trying to learn this way in any language. Better to look for a more structured, probably a good book. It is even possible for a person to create their own study method if they already have a good programming domain and are strongly self-taught with a proven structure. Do not try to guess what things are doing, learn what they really do and how to use it. programming can not be based on shrewdness, voluntarism and trial and error. Look for the documentation. This is the trick.

Just to complement, since the question does not talk about it, but the other answer is misleading : C, like Python, has types for all data. C, unlike Python, has types for all variables. The types available in C are: char , signed char , unsigned char , short , unsigned short , int , unsigned int , long , unsigned long , long long float, double, unsigned long long , long double , or _Bool (available in virtually all compilers), bool , struct , array, and pointer.

There are still some purely library-defined types, including (not all) union , size_t , intN_t , int_leastN_t , int_fastN_t , intptr_t , included in intmax_t and <inttypes.h> .

Pointers and arrays end up somewhat confusing .

Pointers, just like arrays , are always used in composition with other types. It serves both as a reference for a type and for indicating a sequence of data of its type. The pointer can be composed even with functions. The string concept only exists even in the literal quoted and some functions in <stdint.h> , in the background it’s just a pointer to <string.h> .

You can create your own types, usually through char and struct .

I understand what the other answer meant, but it’s good to make it clear that typedef of Python has a very different semantics than dict . Actually I think a better comparison would be the Python class with the C structure. At least in the simplest form of the class, it looks like a struct , although it does not give the same guarantees. In fact the way to simulate a class in C is with struct . Simulating a struct requires something even more complex on its own or using a ready library.


The C language does not have Classes and / or modules such as Python, Java, or C ++. The closest to this are the structs that resemble the dict in python.

For the variables, C has int (inteiro) , char (caractere) , char* (texto) , float (ponto flutuante) , long int , and others.

In addition to these types of variables, it has structs that works very similar to objects, so much so that in C ++, a struct can represent a class with destructor constructors.

The commands dir() and help() , only exist in python, at least all other languages I worked with do not have these functions. In C, you have to look at the documentation, or see the type of input and output value of the methods through IDEs.


Leave a Reply

Your email address will not be published. Required fields are marked *