Category Archives: C language (en)

C language: “can’t bind to the port” problem (Windows)

Sometimes your program process can stuck and trigger error like this: Couldn’t bind to the port Ok, we have such check in out sockets C code: if (bind (socket_desc, (struct sockaddr*)&server_addr, sizeof(server_addr)) < 0) printf(“Couldn’t bind to the port\n”); And … Continue reading

Posted in C language (en) | Leave a comment

C language: NCURSES basics

NCURSES – it is a C library which control process of sending a series of bytes by terminal. It’s quite oldschool approach, but it’s widely used even right now as internet works the same way: packets sending just series of … Continue reading

Posted in C language (en), Programming (en) | Leave a comment

C language: compile and run in Notepad++

In top menu press “Run” and enter there… Example: cmd /c cd “C:\Users\n\Desktop\” && gcc 1.c -o 1.exe && 1.exe There we say to Notepad++: cmd – run terminal /c means to close cmd terminal after program finished; you can … Continue reading

Posted in C language (en), Notepad++ (en) | Leave a comment

Create a Makefile for gcc in Visual Studio Code

Install MinGW (how to set up MinGW – watch this video) Inatsll Visual Studio Code (VSC) you can immediately integrate VSC with Git so that everything is automatically synchronized. To do this, simply make a repository on Github and clone … Continue reading

Posted in C language (en) | 1 Comment

C Language: Dictionary Spell Checker

At the end of the fifth week of the CS50 Harvard course, we studied hash tables, which can be used to solve the problem of hashing words from text to check their spelling in a dictionary (speller.c). A dictionary is … Continue reading

Posted in C language (en) | Leave a comment

C language: inheritance of blood type of family members

In the fifth week of the Computer Science – CS50 (Harvard) course, we studied data structures and learned how to access structure elements by their address. To complete your homework (Lab 5 – inheritance.c), you need to understand the scientific … Continue reading

Posted in C language (en) | Leave a comment

C Language: Simple Random Number Generator

Random number generator in C with srand() and time(). Srand() is a helper function for the rand() function, generating a seed for the start of a sequence of (pseudo)random numbers. Because the time returned by the time() function changes once … Continue reading

Posted in C language (en) | Leave a comment

C language: recover photos from memory card

Imagine that you deleted photos from your memory card and then wanted to restore them. It turns out that in some cases it is possible to do this, because when we delete a photo with the “delete” button, what actually … Continue reading

Posted in C language (en) | Leave a comment

C language: a filter that highlights the edges of objects in an image

At the end of the fourth week of the CS50 (Harvard) course, we had an interesting task: to make a program that takes the original image and imposes a filter on it with selection of the edges of objects (filter-more). … Continue reading

Posted in C language (en) | Leave a comment

C language: change file sound volume

In the fourth week of the CS50 (Harvard) course, we learned how to work with memory, which will help you perform a laboratory work on changing the volume of the sound in a .wav file using a program that receives … Continue reading

Posted in C language (en) | Leave a comment

C language: Apply a filter to an image

In the 4th week of the CS50 (Harvard) course, we studied the principles of working with memory and data arrays. We were faced with the task of writing a program that will apply filters to the original image (filter-less). You … Continue reading

Posted in C language (en) | Leave a comment

C language: addresses and pointers

An example of how addresses are stored in memory: #include <stdio.h> #include <stdlib.h> int main(void) { int* x = NULL; printf (“address of new pointer-type variable x: %p\n”, &x); printf (“value of variable x: %p\n”, x); x = (int*) malloc(sizeof(int)); … Continue reading

Posted in C language (en) | Leave a comment

C language: Swap variables

A curious feature: howto swap numeric variables ezpz without a buffer using the bitwise XOR operation (bitwise exclusive OR): #include <stdio.h> int main(void) { int a = 3; int b = 5; printf(“a = %d, b = %d\n”, a, b); … Continue reading

Posted in C language (en) | Leave a comment

C language: sorting lab

We continue the course cs50, week three, sorting algorithms. It’s time for the lab. It is very simple: download test setup: https://cdn.cs50.net/2021/fall/labs/3/sort.zip inside the archive there are three already compiled C programs: sort1, sort2 and sort3 are binaries, i.e. binary … Continue reading

Posted in C language (en) | Leave a comment

C Language: Recursion Exercises

To learn recursion you need to pump up some muscles. To do so – make some of exercises  which are listed below. If something did not work out, you can peep the solution. Most likely the next day you will … Continue reading

Posted in C language (en) | Leave a comment

C Language: Recursion and the Collatz Conjecture

We continue to take the Computer Science CS50 course and the C language. We study recursion using the example of the Collatz hypothesis – an interesting (and easy to understand) mathematical problem that has not yet been solved by scientists. … Continue reading

Posted in C language (en) | Leave a comment

C language: multi-round voting

In the third week of the Computer Science CS50 (Harvard) course, it is proposed to do homework in Problem Set 3 called runoff.c – you need to write a program code that does not just calculate which candidate received the … Continue reading

Posted in C language (en) | Leave a comment