Hanz
It seems the only difference betweens binary or text is how to translate \n to end of line. So it seems not a good ideal to detect whether a stream is binary or text
Oh wait, I thought you asks about whether or not a file is being opened. In this case, would that be efficient if you store what the user input? Opening file requires specific mode, this should've been stored somewhere on your own.
ZM
Hello , i'm new at coding . Is code blocks C /++C safe to download on my PC ?
ZM
If i find a tutorial i will , thank you
Er Manu
hi, i have a question, what are debug symbols?
Anonymous
I replaced all my raw pointers with shared_ptr's and I'm using only make_shared, but something strange is happening... After all variables going out of scoped, I'm having 84 constructor calls (expected), but only 14 destructor calls https://pastebin.com/Zh7Yv9YL
This is wrong. You are using a shared_ptr to represent both children and parent node relationship. Now if a child node points to the parent and the parent points to the child using shared pointers,think how these objects can be freed. They can't because the reference count for neither the parent nor the child nodes will get reduced. This is a situation where you should use a raw pointer. The relationship from parent to child should use a shared_ptr/unique_ptr. The relationship from child back to parent should be a raw pointer.
Pavel
I think unique_ptr wouldn't work because they are all tree nodes and I need to access them from many different function, with ownership, like insert, remove, rotate
Is it all multithreaded? Or why don't you let your structure (whether it's tree or a generic graph) own the objects?
𝗝ลѴỈ3𝚪Θ
Hi. Anyone was compile c/c++ for anbernic 351 machines or similar?
Anonymous
Hi,when installing a mingw on w7 thes are facing a issue about download faild any solution?
Hussein
Hi,when installing a mingw on w7 thes are facing a issue about download faild any solution?
you may have problem with your internet connection which is irrelevent of the installer
Anonymous
"The relationship from child back to parent should be a raw pointer" Could I use a weak_ptr instead?
No. If you use a weak_ptr, then a shared_ptr must exist or have existed. But you don't want a shared_ptr at all from child back to parent. So in this case it is ok to use a raw pointer. We are not going to have child nodes when a parent node does not exist. So having raw pointers in the child node is not a big design issue and infact is the recommended solution in such cases.
Anonymous
Anonymous
Lyroy
I managed to make the foreach work in the CMakeLists, I don't know why it didn't before...
Pavel
no. only one benchmark
So I finally got my hands on it. I see comparable results on both gcc and clang (differences fluctuate from run to run, and are very small), so they run basically the same in this case https://quick-bench.com/q/duWjGxfX8F1Zog0Yi2RnGV0CaAc What is different with your benchmark?
Ольга
Good afternoon again. If possible I would like to ask. I don't understand why I have a problem with the file format. If all I do is just insert pieces of working code? Is this a problem in the compiler itself or am I doing something wrong. I will be grateful for any help https://onlinegdb.com/LCoI4ShcX
Anonymous
Good afternoon again. If possible I would like to ask. I don't understand why I have a problem with the file format. If all I do is just insert pieces of working code? Is this a problem in the compiler itself or am I doing something wrong. I will be grateful for any help https://onlinegdb.com/LCoI4ShcX
Replace do...while with a while loop, "read" returns bytes not total amount of items, so line 51: if (read == 0 && !feof(file)) { printf("File format incorrect.\n"); return 1; }
Anonymous
is there some built-in function in c++ to determine if a filesystem::path is image?
Ludovic 'Archivist'
is there some built-in function in c++ to determine if a filesystem::path is image?
There is not. That would require opening the file for examination. You could the analyse the start of the file to see if it could be a known image format, or you could analyse the whole file to see if it is a valid image of that format
Ольга
Good evening again! I faced that I do not know how it is possible to compare in an element of structure. For example, car numbers АВ123НР, ВА445СН and the like. Identify only those numbers in which consist of different digits. For example, after work I need the program output AB123HP. I will be grateful for any help or a link to the necessary information because I can not find anything like that
Ludovic 'Archivist'
is there some built-in function in c++ to determine if a filesystem::path is image?
There are dozens upon dozens of image formats and standardizing this introspection would definitely require insane work
Ludovic 'Archivist'
Good evening again! I faced that I do not know how it is possible to compare in an element of structure. For example, car numbers АВ123НР, ВА445СН and the like. Identify only those numbers in which consist of different digits. For example, after work I need the program output AB123HP. I will be grateful for any help or a link to the necessary information because I can not find anything like that
First of all, you will need to do some analysis of the character string that makes up the car number. C++ comes with the guarantee that any UTF-8 character with a codepoint below 128 will be correctly stored in a string. It also guarantees that the C function isdigit will work, allowing you to extract each digit in something of type char. Things of type char can be compared for equality, and it will require exactly 3 comparisons to do your thing
Ludovic 'Archivist'
you may want to: - count how many digits you have - allocate memory for every digit - store every digit - compare then you can also compare in place, but it may seem less intuitive upon reading it
MᏫᎻᎯᎷᎷᎬᎠ
What field do you guys find it exciting in C++?
Ludovic 'Archivist'
What field do you guys find it exciting in C++?
I have seen all sorts of fields using C++, it is a very flexible language and can do almost anything. I am personally passionate about database engineering and distributed systems development. It is widely applicable and a very complex field with lots of resources to delve in and learn from
MᏫᎻᎯᎷᎷᎬᎠ
I didn't know there was such field called "Database engineering"
Leovan
Weird question, but anyone knows why construct float instead of cast to float is better? int x; (float)x; // cast to float float(x); // construct float
Ludovic 'Archivist'
Can you tell me what are those fields? I know only two main ones : Gaming, system programming
Finance and insurance, embedded development, communications and networking systems, desktop applications development, video and audio processing...
Ludovic 'Archivist'
I didn't know there was such field called "Database engineering"
I would qualify it as the study and design of tools for perennial manipulation and access of structured data
Ludovic 'Archivist'
Meaning writing database engines, query protocols and ensuring constraints on both of those
Ludovic 'Archivist'
For example, ensuring data consistency, data access, enforcement of linearisation or serialization constraints etc etc
MᏫᎻᎯᎷᎷᎬᎠ
For example, ensuring data consistency, data access, enforcement of linearisation or serialization constraints etc etc
Serialization constraints? Like what constraints are applied when converting some disk data to SQL query result?
Ludovic 'Archivist'
What is query protocol?
Protocols or APIs to access the data in the database. For example, SQL, pgsql, Transact-SQL, MongoDB BSON queries... are formats for queries (they represent the semantics/meaning of the query) and they rely on network protocols or APIs to be effectively used
Ludovic 'Archivist'
Serialization constraints? Like what constraints are applied when converting some disk data to SQL query result?
The most common constraint is ordering of operation, which gives a strict ordering on which several transactions appear to have been performed. This is of crucial importance to ensure transactions do not "overlap" and stop being isolated
Ludovic 'Archivist'
A question that always occurs to me: what happens when two or more transactions are received at the same time, like which one will be chosen?
Every database system may have a different way to handle it. Some have a transaction counter that acts like an extremely fine unit of time that is added to every received query (like as pico seconds for example) to ensure no 2 transactions actually have the same time. Some like Spanner try both transactions and if there is interference it cancels one and executes the other based of atomic clock timestamps later so it is less common for it to need the fine grained time. All things considered the notion of time is very arbitrary and we mostly stick to happens before and happens after semantics
Anonymous
Hello everyone in structure i have 1 problem that if i want to write the full name it doesn't print full name, it just ignore what is after the space anyone have idea ?
Anonymous
Use gets function
Anonymous
Anonymous
Take a. Char array ...
Anonymous
And them put the string buff in the array ...
Anonymous
And print
tasya
int n= 80; float *next = 12.5; i.Write a command to display ptr value ii.Declare a pointer ptr2 of float type. iii.Write a command to display the address of ptr2 pointer.
tasya
can anyone help me with this
tasya
#include <iostream.h> void main() { char letter[ _i ] = {'A', 'B', 'C', 'D', 'E', ‘F’, ‘G’, ‘H’, ‘I’, ‘J’}; for (int i=0;i <10;i++){ cout<< __ii___ cout<< endl;} } what the answer for ii?
\Device\NUL
> iostream.h
\Device\NUL
Use gets function
gets() is no longer on C11 and above
● Igor
How to solve this problem? Node depends on Connection, and Connection depends on Node. When it is a function you can just declare the contract and later you write the implementation class Node { public: int data; vector<Connection> neighbors; Node(int data) : data(data) {} }; class Connection { public: Node *node; int distance; Connection(Node *node, int distance) : node(node), distance(distance) {} };
Rasel
#include <bits/stdc++.h> using namespace std; int main() { int s=0,n; cin >> n; for(int i=1;i<=n;i++) { s=s+pow(-1,i)*i; } cout<<s<<endl; return 0; }
Rasel
how can i avoid time limit exceed on this code?
Rasel
If i%2 == 1 then pow(-1,i) is -1 else it is 1.
#include <bits/stdc++.h> using namespace std; int main() { long s=0,n; scanf("%ld",&n); for(int i=1;i<=n;i++) { if(i%2==0) s=s+i; else s=s-i; } cout<<s<<endl; return 0; }
Rasel
again limit exceed on 100000000000000000 test
Deleted account
hello
Deleted account
where can I practice my c skills
Deleted account
\Device\NUL
You can practice by solving competitive programming problem or doing some project