itsmanjeet
> also please share the forum post url. What do you mean?
link to the post so that i can follow up there
Danya🔥
What post are you talking about?
itsmanjeet
There are some tricks to reduce build time 1. Use ninja build system 2. Use lld or mold linkers instead of the standard ld
ye, last option, dev on windows sucks. and I thought visual studio will make life easy but
itsmanjeet
Cool I'd still share your problem with other folks on forum and the actual solution to it if you find one It'd useful for others
Got that working, they have a seperate repository for precompiled llvm with required files and configuration and available that with FetchContent ❤️ include(FetchContent) FetchContent_Declare( LLVM_Windows URL https://github.com/c3lang/win-llvm/releases/download/llvm_16_0_2/llvm-16.0.2-windows-amd64-msvc17-libcmt.7z ) FetchContent_MakeAvailable(LLVM_Windows) set(CMAKE_SYSTEM_PREFIX_PATH ${llvm_windows_SOURCE_DIR} ${CMAKE_SYSTEM_PREFIX_PATH}) find_package(LLVM REQUIRED CONFIG) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
Telfer
Hi I’ve got an issue
Danya🔥
Telfer
Lol. When I code without using cin it runs
Telfer
Bu when I cin it doesn’t
itsmanjeet
Bu when I cin it doesn’t
compilation issue?
Telfer
Wish I could send a pic here for a detailed explanation
Manav
Wish I could send a pic here for a detailed explanation
You can add the detailed explanation with your error message in a pastebin
Telfer
Okay
labyrinth
Well a lot of companies use open addressing hashtables because they are more cache efficient
yeah, I was looking at clickhouse implementation of hash table in which it has comments saying that any modern hash map use open addressing. It is quite hard for me to understand tho, looking forward to a tutorial
Ludovic 'Archivist'
Anonymous
yeah, I was looking at clickhouse implementation of hash table in which it has comments saying that any modern hash map use open addressing. It is quite hard for me to understand tho, looking forward to a tutorial
Open Addressing is used. But you are asking for linear probing which is seldom used. Like I mentioned in my previous post, linear probing results in clustering around specific points which is why it is avoided. It doesn't distribute the values around. Other probing methods like Double Hash and Triple hash avoid this problem which is why they are often used. Quadratic probing may also be used.
Ludovic 'Archivist'
Open Addressing is used. But you are asking for linear probing which is seldom used. Like I mentioned in my previous post, linear probing results in clustering around specific points which is why it is avoided. It doesn't distribute the values around. Other probing methods like Double Hash and Triple hash avoid this problem which is why they are often used. Quadratic probing may also be used.
Linear probing is actually used by most of those large hashtables, but with a catch: to reduce clustering, you need to sacrifice a byte of the hash to transcribe an offset in a table of offsets that evolve following an exponential curve. This limits clustering massively and is configurable to improve it's performance depending on the task
Ludovic 'Archivist'
Double hash and triple hash are... very bad when performance is needed
Anonymous
Double hash and triple hash are... very bad when performance is needed
Hashing is typically a fast operation. You are not looking at cryptographically secure hash algorithms to probe a free spot in the hashmap anyway for them to be slow. I don't understand why that would slow down performance so much. Can you please clarify that?
Ludovic 'Archivist'
Ludovic 'Archivist'
I understand what you are suggesting here. This would indeed distribute them but can I see an implementation that does this if you know of any
Bytell does that but with many extra tricks up its dirty sleeve https://github.com/skarupke/flat_hash_map/blob/master/bytell_hash_map.hpp
Ludovic 'Archivist'
A talk about that hash map https://www.youtube.com/watch?v=M2fKMP47slQ
Anonymous
Bytell does that but with many extra tricks up its dirty sleeve https://github.com/skarupke/flat_hash_map/blob/master/bytell_hash_map.hpp
This is not linear probing. This is an exponential probing. The way he has improved performance is by precomputing the jump distances for finding the next free spot. The largest entry in his jump_distances array is large enough to accomodate a very large hash map. Typically when people say linear probing, they mean that the next spot to be checked is a linear function of the previous spot. This is what leads to clustering. In his case, the next free spot is not a linear function of the previous spot (except in the case of the first 16 entries). He uses triangular number sums beyond that which is essentially an exponential function. The fact that he calculates the jump distances using an offset into an array doesn't make this linear probing
Ludovic 'Archivist'
Make it work, make it clean, make it fast, in that order
Ludovic 'Archivist'
Linear probing is also great for making perfect hashtables (or near perfect ones)
$úrèndra çhoudhary
hi can anyone help me
$úrèndra çhoudhary
how to increase windows height and use it like this and access visible part by scrolling or any application to do this
Kasra
Hello friends, good time, honestly, I am seventeen years old, I learned C++ in a preliminary way, but I don't pursue a specific field or goal with it, and I don't want to choose my field before it's too late. The atmospheres that I had, the field of front-end is less educational and I chose c++ just to enter the world of programming faster and I took Jolo, but I am not really pursuing a specific field with it, should I continue with c++ or enter the web field On the other hand, I am interested in working with other technologies and I would like to know how a site can be raised from zero to one hundred and to learn more practical programming than to get to know the logic of programming. Thank you for your help.
Pavel
Hello friends, good time, honestly, I am seventeen years old, I learned C++ in a preliminary way, but I don't pursue a specific field or goal with it, and I don't want to choose my field before it's too late. The atmospheres that I had, the field of front-end is less educational and I chose c++ just to enter the world of programming faster and I took Jolo, but I am not really pursuing a specific field with it, should I continue with c++ or enter the web field On the other hand, I am interested in working with other technologies and I would like to know how a site can be raised from zero to one hundred and to learn more practical programming than to get to know the logic of programming. Thank you for your help.
C++ is not the first language to use when it comes to web. As far as I know in web it mostly used on high load backend servers (like search engines), and even there it is often being replaced with other technologies because of the complexity to write safe code in C++. If your main focus is web, I would suggest trying languages/technologies related to web sooner than later, C++ (or maybe even C) may be nice to learn to understand how things work under the hood, but the first thing you would need in practice is the technologies that are prevalent in the area of your interest. And if you don't want to choose now, then just learn whatever language is fun for you. The core concepts are very similar between most of the languages, learning the second language is far easier than learning the first one.
C
are empty constructors common in C++?
B
Hay Is anyone here know about MIPS Architecture model 🙂
Danya🔥
Hay Is anyone here know about MIPS Architecture model 🙂
No one cares about it, even its own company
B
Hay Is anyone here know about MIPS Architecture model 🙂
I have some problems with J type instruction format
Pavel
are empty constructors common in C++?
Yes, but people usually default them in that case. class A { A() = default; ... }; The reason to have such constructors is usually that all the members are user-defined types (classes) that initialize themselves. In very rare cases initialization can be skipped to save a few operations. Or people can also rely on the fact that POD types (not sure what is the correct name for them) are zero initialized in some scenarios. Defaulting is better than defining an empty constructor because it allows some optimizations (defaulting is technically a bit different than having an empty constructor from the compiler point of view).
B
Convert the following MIPS assembly instructions into machine language using jump type instructions format j 0×0040001C This is my problem.Please anyone can help with this
Anonymous
I have a question about the arrays: a[7][5] is the same as a[7*5] ?
Anonymous
I have a question about the arrays: a[7][5] is the same as a[7*5] ?
There is some difference between these notations, because at the end the same amount of elements are stored.
Ziky
I have a question about the arrays: a[7][5] is the same as a[7*5] ?
At least in case of plain C arrays it is the same. by declaring int a[5][7] language will reserve 5 * 7 * sizeof(int) bytes for you starting at address stored in pointer a
klimi
afaik it is just a syntax sugar (the [][] notation)
Ninja
OT freelancer?
Ziky
Why do you think so?
Paulo
Guys anyone working with open-source project that want someone to contribute?
Pavel
Guys anyone working with open-source project that want someone to contribute?
I'm working on a small 2D game, and would like some help from someone who is ready to learn opengl to help me with rewriting the graphics pipeline :) https://github.com/gameraccoon/tank-game/
莉莉亚娜🇨🇳
Hello, how I get: wchar_t *example=L"ñ"; printf( "%x\n", (unsigned)example[0]); but with: wchar_t *example=argv[1]; and get the same with the character "ñ"
莉莉亚娜🇨🇳
If it’s standard C, argv[1] is encoded in ASCII, and you can’t really get wide character from it
I try to do this: int convert_to_opcodes(char *parts) { wchar_t *parts0; //wcstombs(parts, parts0, 1); //I get c3 //mbrtowc(parts0, parts,1,NULL); //I get c3 mbtowc(parts0, parts,1); //I get c3 return wctob(parts0[0]); // I get c3 //return (unsigned)parts0[0]; //normal method but the same, c3 }; int main(void) { // not the same, I get c3 with "ñ" printf("Opcode: %x\n", convert_to_opcodes("ñ")); // with "ñ" I get c3 // simple example wchar_t *example = L"ñ"; printf("Opcode: %x\n", (unsigned)example[0]); // with "ñ" I get f1 <- this is correct return 1; }
莉莉亚娜🇨🇳
I have these results on my machine: Opcode: ffffffc3 Opcode: c3 It seems that I can't get 0xf1 to recreate that. If you want wchar_t * from argv, try GetCommandLineW if you're on Windows
Ok I do it in console (windows), and I get f1, for some reason... but when I run in sublime I get c3 with the function and the simple example a get f1
莉莉亚娜🇨🇳
In sublime I don't know* how that build the code, but when I build in Windows I use $ gcc -o example.exe example.c
%Nikita
In sublime I don't know* how that build the code, but when I build in Windows I use $ gcc -o example.exe example.c
Compiler flags definitely don’t affect source file encoding. Try to save source in notepad for example with UTF-8/Windows12XX and see how it will change
莉莉亚娜🇨🇳
How can I convert this: int main(int argc, char *argv[]) { char str[] = "Hola"; char *ptr = (char *)(str[0] & 0xFF); //the program stop printf("%s\n", ptr); } I want to get the first string of str 'H' or other, example 'a' or 'o' and convert to char...
Danya🔥
How can I convert this: int main(int argc, char *argv[]) { char str[] = "Hola"; char *ptr = (char *)(str[0] & 0xFF); //the program stop printf("%s\n", ptr); } I want to get the first string of str 'H' or other, example 'a' or 'o' and convert to char...
The code you've provided seems to have some misunderstandings and issues. Let's break down what's wrong with it: int main(int argc, char *argv[]) { char str[] = "Hola"; char *ptr = (char *)(str[0] & 0xFF); //the program stop printf("%s\n", ptr); } 1. Type Mismatch: The main issue in this code is a type mismatch. str[0] is of type char, and when you perform str[0] & 0xFF, you're performing a bitwise AND operation with an integer constant 0xFF (which is 255 in decimal). The result of this operation is an integer value (0 to 255). Then you're trying to assign this integer value to a pointer of type char * (i.e., char *ptr). This is incorrect because an integer value cannot be directly assigned to a pointer. 2. Undefined Behavior: Even if you were to cast the integer value to a pointer type, attempting to print the string pointed to by ptr using %s in the printf function would lead to undefined behavior. The value resulting from the bitwise AND operation is not guaranteed to be a valid memory address, and attempting to interpret it as a C-style string would result in unpredictable behavior, including program crashes or incorrect output. Here's how you might fix the code to make it work correctly: int main(int argc, char *argv[]) { char str[] = "Hola"; char *ptr = &str[0]; // Assign a valid memory address to the pointer printf("%s\n", ptr); return 0; // Return 0 to indicate successful execution } In this corrected code, ptr is assigned the address of the first character in the str array. This is a valid memory address, and printing the string starting from this address using %s in the printf function will work as intended. Additionally, don't forget to include a return 0; statement at the end of the main function to indicate successful program execution.
VD
The code you've provided seems to have some misunderstandings and issues. Let's break down what's wrong with it: int main(int argc, char *argv[]) { char str[] = "Hola"; char *ptr = (char *)(str[0] & 0xFF); //the program stop printf("%s\n", ptr); } 1. Type Mismatch: The main issue in this code is a type mismatch. str[0] is of type char, and when you perform str[0] & 0xFF, you're performing a bitwise AND operation with an integer constant 0xFF (which is 255 in decimal). The result of this operation is an integer value (0 to 255). Then you're trying to assign this integer value to a pointer of type char * (i.e., char *ptr). This is incorrect because an integer value cannot be directly assigned to a pointer. 2. Undefined Behavior: Even if you were to cast the integer value to a pointer type, attempting to print the string pointed to by ptr using %s in the printf function would lead to undefined behavior. The value resulting from the bitwise AND operation is not guaranteed to be a valid memory address, and attempting to interpret it as a C-style string would result in unpredictable behavior, including program crashes or incorrect output. Here's how you might fix the code to make it work correctly: int main(int argc, char *argv[]) { char str[] = "Hola"; char *ptr = &str[0]; // Assign a valid memory address to the pointer printf("%s\n", ptr); return 0; // Return 0 to indicate successful execution } In this corrected code, ptr is assigned the address of the first character in the str array. This is a valid memory address, and printing the string starting from this address using %s in the printf function will work as intended. Additionally, don't forget to include a return 0; statement at the end of the main function to indicate successful program execution.
The result of str[0] & 0xFF is str[0] itself if char is 8 bits long which it is on almost every architecture. I don't see why he has to do that to begin with. Also why not just do printf("%s", str) instead of assigning it to a pointer. Also char* ptr = str; would be a much more concise version of char* ptr = &str[0]; The return 0 at the end of main is redundant. According to CPP Core guidelines, you use return statements in main only when returning error codes or if you are returning early.
Anonymous
I found this list of fundamentals that would be very important to have in order to have a solid foundation in programming, among them, what do you think should be the start for a total beginner? Data Structures and Algorithms Computer Architecture Theory of Computation Operating Systems Compilers Discrete Math
Anonymous
And it depends on what your end goal is
I want to have a strong foundation in programming in general, I'm doing systems analysis and development, but I really wish I'd started computer science
Anonymous
Are you able to program something?
just basic programs like calculators, nothing too complex, I have a very basic knowledge of programming logic, and I started a C++ course the day before yesterday.
Anonymous
I even thought about starting to read the book: Code: The Hidden Language of Computer
Danya🔥
I found this list of fundamentals that would be very important to have in order to have a solid foundation in programming, among them, what do you think should be the start for a total beginner? Data Structures and Algorithms Computer Architecture Theory of Computation Operating Systems Compilers Discrete Math
Well studying compilers in-depth is not useful unless you want to work on them or related fields, so I'd say the number one priority is data structures and algorithms, then operating systems and computer architecture, then everything else
ᴍᴏʜᴀᴍᴇᴅ
I made a mistake and used Python at the beginning, and I don't know anything about algorithms, data structure, problem solving, and I'm not good at programming. I want to deal and understand anything low level, develop kernels and os, learn embeded systems programming, learn c and c++, and assembly can also, so what do you advise me?
HOOS
Question, do you know any communities or people participating through code challenges or conferences , that would help build up teams or something like that?
Danya🔥
Victor
Hi everyone! Is here a channel with cpp vacancies?
Victor
That would be so cool to make this channel
Victor
?
Victor
What is that?
Danya🔥
That would be so cool to make this channel
No, it would not because it's an international chat and it doesn't make a lot of sense
Danya🔥
https://t.me/ProCxxJobs If you need C++ job postings in Russia, use hh.ru, websites of the big companies or this channel — https://t.me/ProCxxJobs
Danya🔥
Also, Tinkoff just started to accept applications for the fall internship