Linux equivalent of I_PUSH

TIOCPKT is exactly what you want, according to the tty_ioctl(4) man page: the argument is a pointer to an integer which is non-zero to enable packet mode, or zero to disable it.

Expression preceding parentheses?

The error is referring to this line: Here you’re (apparently) trying to call delay as a function. However, delay is declared as: It’s just a number, not a function, hence you can’t call it.

Categories C Tags

Reading a string with scanf

An array “decays” into a pointer to its first element, so scanf(“%s”, string) is equivalent to scanf(“%s”, &string[0]). On the other hand, scanf(“%s”, &string) passes a pointer-to-char[256], but it points to the same place. Then scanf, when processing the tail of its argument list, will try to pull out a char *. That’s the Right Thing when you’ve passed in string or &string[0], but when … Read more

where does stdio.o live in linux machine?

I’d suggest that you run gcc -v your_file.c. That will let you see exactly what commands your linker is using. You probably don’t have an stdio.o file to link against. Instead this is included in the C runtime library and the exact file will depend on your system configuration.

Invalid pointer error on invoking free() after malloc in C

I am doing very basic dynamic allocation practice in C and I came across this issue: when I am trying to call free() with the pointer returned by malloc(), I am getting Invalid pointer error during run time. When I remove free() from code, it works fine. The pointer that I am using is not modified anyhow after returned by malloc (except … Read more

How do you pass a function as a parameter in C?

Declaration A prototype for a function which takes a function parameter looks like the following: This states that the parameter f will be a pointer to a function which has a void return type and which takes a single int parameter. The following function (print) is an example of a function which could be passed to func as a parameter because it is … Read more