c

A function that checks whether a number is prime

You need to check whether the number is prime using the function. I decided like this, but it does not work completely correc ... or ( int i = 2; i * i <= num; i++ ) { if ( num % i == 0 ) { return 0; } } return 1; }

Sorting by inserts (modify the algorithm)

Write a sorting algorithm. But not quite the insertion sort, the algorithm needs to be modified a bit. I made an illustration ... ar[j].sq; j--) { coord t = ar[j]; ar[j] = ar[j - 1]; ar[j - 1] = t; } } }

How to translate a number from one number system to another without using real data types

The program receives two numbers b1 (the original number system) and b2 (the one to be converted to) and a number X (maximum ... ) ? tmp+'0' : ((10 <= tmp && tmp <= 26) ? tmp +'A'-10 : 0)); printf("%c",ch ); } return 0; }

What is the difference between static and dynamic linking?

What is the difference between static and dynamic linking? Why is it that when these phrases are Googled, the result is giv ... VS : dynamically or statically? But still, the main question is: what is the difference between static and dynamic linking?

Extra character with the code " -1 " before EOF

When writing the content from the input file to the output file, another character with the code "-1" is read before the end ... t_file); /*fwrite (str, sizeof(char), i, output_file);*/ free (str); if (feof(input_file)) printf ("END FOUND\n"); }

Zero-size objects and zero-length arrays

Please tell me what the C and C++ standards say about zero-length objects? On the one hand, everyone says that the size of a ... f any object should not be equal to 0. This may not apply to the minimum object size requirement, but it further confuses me.

Can't open file for reading

The code is as follows: if ((pfp = fopen("etc/enet.cfg", "r")) == NULL) { printf("Unable to open enet.cfg\n"); return -1; } The file cannot be opened, i.e. an error message is printed in this case.

strcpy function - version with pointers

Reading the book by Brian Kernighan on the C programming language, I liked the example of implementing the strcpy function, b ... t, "Hello world"); } Please explain in simple words. You can also give a comment on the first method, thank you in advance!

Calculating the sine using the Taylor series

In this problem, we need to calculate the sine of the argument, and the use of the sin function is prohibited, that is, we us ... double x; for(int i=0; i<N; i++){ scanf("%lf\n", &x); printf("%0.15lf\n", Sin(x)); } }

Buffering data in C

Hello everyone. I am interested in the following question. Input / output to standard streams in C (stdin/stdout) is buffered ... buffer are written to the file? I also can't understand why fflash () is needed. Please explain in simple language. Thank you

How do I write an array of numbers to a file?

New to C, I can't figure out how to write an array of regular int's to a file.

Syntax for writing C values

Hello everyone, I came across an article on the Internet on working with memory in C++, where I found this line of code: *(PD ... sterisk sign at the beginning, but at the same time there is a conversion to the pointer to DWORD type, why specify it twice?

Sharing scanf and fgets

It was necessary to count an integer, and then a string. I wrote this code: #include <stdio.h> #include <string.h> ... dumped core ./Playground/runner.sh: line 88: 12 Segmentation fault timeout "$runtime" "$output" - What's the matter?

Number of decimal places in c++

You need to output the result of dividing two numbers with an accuracy of 10^-9 Examples: 19/7 - вывод 2.714285714 3/2 - в ... th std:::cout << res - the accuracy will be only 10^-5 (instead of the desired 2.714285714 when 19/7 is output 2.71429)

Is it possible to write curly brackets in #define?

I found this code: #define OpenThen(hkey_key, lpcwstr_subkey, callback) { \ HKEY _k = 0; \ if (ERROR_SUCCESS != RegOpenKeyEx( ... parameters work? It turns out that the macro parameters are just any strings that will simply be substituted into the token?

Question about the fork () function. 3 passes through the code instead of 2

I study processes in Unix. I encountered a misunderstanding of the fork () function. As far as I know, the function must pass ... - 30007 Я потомок Я родитель, мой ребёнок - 0 Tell me what could be the problem? What is a process whose child has PID == 0?

error: ‘NULL’ undeclared

File null. c. int main() { void *p = NULL; return 0; } I build using gcc. $ gcc null.c I get an error. Null.c: In function ‘main’: null.c:2: error: ‘NULL’ undeclared (first use in this function) What's wrong?

A simple, cross-platform C-compatible sound library

Searching the Internet, I found SoLoud, but I can't collect it.There are all sorts of sdl, dumb and other stuff, but my tasks ... he simplest and smallest library for working with sounds, working on both Windows and Linux, which is tied to the C language?

Balancing a binary tree

You need to balance the binary tree without using the height field for the element. I see this algorithm so that after each i ... d be very grateful if you can help with the code. P. s I know it's time-inefficient, but that's exactly what the problem is.

Arithmetic operations on Char in C

If the elements of the char array contain two elements read from the keyboard (exactly numbers) and you want to write their sum to the element of the third array, also of the char type, how do you implement this?