указатели
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.
Dereferencing an array pointer
int array[3]{1,2,3};
int (*ptr)[3]=&array;
When dereferencing
std::cout<<*ptr;
(или std::cout<<ptr[0])
по ... address of the next element.
Or does the array break up in std::cout<<ptr[0];, but not in std::cout<<ptr[0]+1;?
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?
how to free up memory with free()
The class creates a structure and a pointer to it.
In the constructor, the necessary memory is allocated for the structure.
A ... the structure.
How do I do this correctly using the free () function ?
if (pData) free(pData->matrix); // это не работает
C2440: Unable to convert const char* to PVOID
I am writing a joke program that will change the image of the desktop:
An error occurred in one of the lines of code:
System ... wears that it is impossible to convert const char* to PVOID. I think I missed something somewhere. What could be the problem?
Pointer reference vs pointer to pointer. C++
Is there any difference in performance, or are there any Pros and Cons to using such a design at all:
Type* a = new Type(); ... be stored / processed roughly as a reference to at a lower level?
I will be grateful for your explanations in this matter.
Why std::find returns a pointer?
Why the find() method uses a pointer. That is, in this example
#include <iostream> // std::cout
#include <algori ... ay. We just need to search for it in the array and that's it. Why can't this be done without a pointer? Thank you in advance!
Pointer to an array of char *tmp; cin>>tmp characters;
Please explain why this code works:
cout << "Test: ";
char *tmp;
cin>>tmp;
cout << "Test: " << tmp << std::endl;
Read access violation at address 0x00000000
#include <iostream>
#include <string>
struct Auto
{
std::string Manufacturer;
std::string TitleModel;
... exception was raised at 0x0F7AF6E0 (ucrtbased.dll) in Task2.37.exe: 0xC0000005: read access violation at address 0x00000000.
Accessing a two-dimensional array via pointers
I need to display an array with a size of about 1000x1000 . If you constantly access the array elements via [] [], it takes a ... ointers. It should also be faster. What is the best way to run through such an array with the shortest time through pointers?
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!
What is the difference between references and pointers in C++
What is the fundamental difference between a reference and a pointer in C++? When is it better to use a reference, and when is a pointer? What are the limitations of the former, and what are the latter?
Why can't I stack pointers?
The exam asked a question:
Why can't I stack pointers?
The difference between pointers returns the number of elements betwe ... should return a certain number, but it turned out that the addition of pointers is not defined. I'm interested in the reason.
How pointers work in C
I'm trying to figure out the pointers. It seems like I started to understand them, but after these two simple functions and t ... 1, &c2);
swap(&c1, &c2);
printf("c1 = %d, c2 = %d\n", c1, c2);
return 0;
}
Result:
с1 = 2, с2 = 1
Why do I need an ampersand in a function parameter?
Please tell me what role the ampersand plays in the parameter of this function because the program works correctly both with ... summands_it)
{
cout << *summands_it << (summands_it != summands.end() - 1 ? " + " : "\n");
}
}
Pointer to pointer - what is it?
I often see this construction:
int ** p;
I understand that this is a pointer to a pointer. Why is such duality necessary and where is it applied?
Pointer notation in C++
Hello.
Are there any significant differences between such pointer definitions:
int* a;
int *b;
I would also like to find ou ... void this:
int var = 123;
int *ptrvar = &var;
int **ptr_ptrvar = &ptrvar;
int ***ptr_ptr_ptrvar = &ptr_ptrvar;
C++, polymorphism, and smart pointers
I have a poor understanding of how smart pointers (especially shared_ptr) interact with polymorphic types. The overall pictur ... // ...
}
}
int main()
{
shared_ptr<Base> base = make_shared<Derived>();
do_something(base);
}
Working with pointers and with C strings
I do not understand why, for example, to output a pointer to int, it first needs to be dereferenced, and when using a pointer ... же находится сама строка
// хотя, я думал, что здесь должен был бы выводиться адрес первого символа строки.
cout << c;
What does return *this c++return?
Return *this returns the object itself, and MyClass & converts as an object reference (well, or MyClass & indicates ... fused
MyClass & operator = (const MyClass& other)
{
// Код...
// Код...
// Код...
// Код...
return *this;
}