Top "C" questions

C is a general-purpose programming language used for system programming (OS and embedded), libraries, games and cross-platform.

What's the best way to check if a file exists in C?

Is there a better way than simply trying to open the file? int exists(const char *fname) { FILE *file; if ((…

c filesystems cross-platform
Reading a string with scanf

I'm a little bit confused about something. I was under the impression that the correct way of reading a C …

c scanf
Use of exit() function

I want to know how and when can I use the exit() function like the program in my book: #include&…

c
What can be the reasons of connection refused errors?

I'm trying to write a server program in C, using another client, I get this error when I try to …

c sockets connection-refused
Difference between malloc and calloc?

What is the difference between doing: ptr = (char **) malloc (MAXELEMS * sizeof(char *)); or: ptr = (char **) calloc (MAXELEMS, sizeof(char*)); When …

c malloc calloc
How to compile and run C/C++ in a Unix console/Mac terminal?

How can I compile/run C or C++ in Unix console or a Mac terminal? (I know it, forget it, …

c++ c macos console terminal
Easily measure elapsed time

I am trying to use time() to measure various points of my program. What I don't understand is why the …

c++ c linux time measurement
Why should we typedef a struct so often in C?

I have seen many programs consisting of structures like the one below typedef struct { int i; char k; } elem; elem …

c struct typedef
Strings and character with printf

I was confused with usage of %c and %s in the following C program #include <stdio.h> void …

c printf
Reading string from input with space character?

I'm using Ubuntu and I'm also using Geany and CodeBlock as my IDE. What I'm trying to do is reading …

c string input scanf whitespace