c

Find the occurrence of a substring in a string in C

Please tell me: there are two arrays of characters that are entered by the user, you need to check them character by characte ... // функция вывода. { index == NULL ? printf("str1 not in str2") : printf("str1 in str2, entry index is: %d", index); }

How to properly glue two strings in C?

When executing the code #include <stdio.h> #include <string.h> int main() { char *first = "first"; char *second = "second"; char *third = strcat(first, second); } A segmentation error occurs.

In the given string, find the longest and shortest word

Task given: In the given string, find the longest and shortest word. Display them on the screen and display their length. T ... ("The longest word is: %s\n", maxword); printf("The least word is: %s\n", minword); return 0; } `

Header in the GET request

I write a program on sockets in C, which sends a Get request to the server and receives the weather in the city in response. ... t=55.75396&lon=37.620393\r\nX-Yandex-API-Key:[ключ] I try to send it like this, but I understand that it is not the same

ASM X86, linux, open file: can't!

Gentlemen, I am trying to understand the magic of syscalls. In C, everything is not very complicated. I tried to do this-fran ... Still after the call syscall the error code is located in the eax register. Tell me, please, what am I doing wrong? Thanks.

How do I create a dynamic C array?

You need to read the number N from the file, create an array NxN , and fully initialize it with 1. Here's how I do it in C++: ... while(!input.eof()) { input>>i>>j; Graf[i][j]=1; Graf[j][i]=1; } How does this translate to C?

Dynamic array of structures

#include <iostream> #include <Windows.h> #include <conio.h> #include <string.h> #include <stdlib.h ... the first entered score is a healthy left number. Well, I would like to hear what kind of shoals immediately catch your eye.

Dynamic vs Static memory allocation

There is a structure: typedef struct Point { int x; int y; } point_t; What is the best way to create an" instance " ... speed, but not infrequently I see the 2 way. So what's the difference (other than being able to do delete whenever you want)?

Assigning the const char character *

Good afternoon, I want to dot the "I" for myself. const char *v = "123d"; const char *c = "123"; c[2] = '5'; / ... here for const char *, and it assigns a new address to it? And when assigning a literal, we try to write to the same address?

Reading a binary file in C

The file contains a structure in binary form, first there is an array of char(word), then a number, and all this is repeated ... strlen(st[i].nam), fp); fread(&(st[i].count), sizeof(int), 1, fp); } fclose(fp);

EOF behavior in C

I needed to write a function to measure the file size in bytes. Here's what came out: #include <stdio.h> #include < ... be equal to one of the bytes in the file? Who invented this? Maybe I missed something. I checked everything 10 times. Magic.

Warning: implicit declaration of function ‘read’ ('write')

Hello. Please tell me why the compiler throws warning when using read and write? #include <stdio.h> #include <string ... translation, it is clear that an implicit function declaration occurred. It turns out that I'm missing some kind of include?

The editing of the C binary file is looped

You must replace every third number in the binary file with the same number with the opposite sign. The numbers are represent ... double), 1, input_file); } } fclose (input_file); free (filename); system ("pause"); return 0; }

Dynamic memory allocation in C

The question will probably seem simple, but not for me. The size is unknown in advance, it all depends on the user's desire. ... w much will need to be added, everything is decided in prime time. Or is everything solved by declaring struct Book** books?

Cyclic array shift

For example, you need to perform a cyclic shift to the right by n elements. And how to make a cyclic shift to the right by -n ... rrect answer is: Array - 1 2 3 4 5 Shift to the right by -2 (negative number) Is the answer 3 4 5 1 2 or 3 4 5 2 1 correct ?

Writing invalid values to an enum or enum class variable

Please tell me, do the rules of the languages C and C++ allow writing an invalid value to a variable of the type enum or enum ... ONE = 1, TWO, THREE }; const C c = static_cast<C>(value);// OK Am I right? And if not, what am I wrong about?

How do I determine if a file is binary or text?

An arbitrary file is given. You need to write a program (C / C++) that determines whether it is text or binary. Is there such an algorithm at the moment? What criteria are appropriate to use?

Translation from the 16th numeral system to the 10th numeral system

Hello. You need to write a program that performs this translation. In the C language. I started writing, but something is not ... scanf (" % s ", &st "); printf("Rezultant: n"); HEX_TO_DEC(st); } What is the error? Thank you in advance.

Type of the register variable

What type of variable is declared with the keyword register? I met this code. What is the type of the n variable here? int main() { register n; }

Ukkonen's algorithm. Linearization of a cyclic string

Suppose I built a suffix tree... I need "Linearize a cyclic string, that is, find the lexicographically minimal section of t ... yclic string" Who has any ideas - how to do it (algorithm)? You can also explain - what is the section of the cyclic string