How to declare multiple different type variables in one line in C language

For example: int a, float b; But it’s wrong. Actually, I want to use it in the for loop. Just like this: for (int a, float b; a < 1; a++) { } I can use for loops to simplify mutex like this #define in_mutex_env(val) for(int __x = ({mutex_lock(); 0}); __x < 1; __x++, mutex_unlock())… Read More How to declare multiple different type variables in one line in C language

I had just started learning programming in C language and I faced a simple problem, but I didn't know how to implement it

I want to write a program that accepts three arguments from the command line. Two arguments are numbers while one argument is one of the operations. The main function should read these arguments, if the number of arguments is not 3, then the program should return the value -9999 and exit. If the number of… Read More I had just started learning programming in C language and I faced a simple problem, but I didn't know how to implement it

I had just started learning programming in C language and I faced a simple problem, but I didn't know how to implement it

I want to write a program that accepts three arguments from the command line. Two arguments are numbers while one argument is one of the operations. The main function should read these arguments, if the number of arguments is not 3, then the program should return the value -9999 and exit. If the number of… Read More I had just started learning programming in C language and I faced a simple problem, but I didn't know how to implement it

How to assign values in an array of arrays properly?

Is there a way to assign values in an array of arrays? Specifically, I have written the following code: #include <stdio.h> #include <stdlib.h> void func(int **A){ //A: address of (address of pointer) int i; *A=(int *)malloc(5*sizeof(int)); //*A: address of pointer for (i=0;i<5;i++){ **A=i; //**A: content } } int main(){ int *k, i; func(&k); for (i=0;i<5;i++){… Read More How to assign values in an array of arrays properly?

Why should i put SEEK_SET twice

I want to modify some vowels of a file by "5". The following code works. However i do not understand why should I put fseek twice. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> void print_file_contents(const char *filename) { FILE *fp; char letter; if((fp=fopen(filename,"r+"))==NULL) { printf("error\n"); exit(1); } fseek(fp,0,SEEK_END); int size=ftell(fp); rewind(fp); for(int i=0;i<size;i++) {… Read More Why should i put SEEK_SET twice