🅸🅼🆁🅰🅽
Microsoft is in a secret program with Windows and GPT to monetize. codename : KILL PROGRAMMING JOBS Software engineers usually forget his own code as he never actually wrote it. So software engineer should not hold any license for their code. Actually software licensing should never happen. It should always be free. So AI can easily enable all the people of the world to write software. Currently software engineers are actually the hindrance of the future. So AI will replace software engineers for sure.
An
Hi. How can I get array elements from+to a specific index. Like in python, array[from:to]?
klimi
Hi. How can I get array elements from+to a specific index. Like in python, array[from:to]?
there is no such straightway how to get a slice. AFAIK You could use iterators to copy the range.
An
there is no such straightway how to get a slice. AFAIK You could use iterators to copy the range.
I know. I am looking for a function like memcpy but from index1 to index2. Is there such a function?
𝔖𝔞𝔯𝔬
I know. I am looking for a function like memcpy but from index1 to index2. Is there such a function?
Use the size parameter void memcopy(void * dest, size_t start, size_t end , void* src){ memcpy(dest , src+ start, end - start); }
𝔖𝔞𝔯𝔬
Bu that is the point of coping from an index to an end
AL
hi guys
AL
i have a question,
AL
I'm currently making a shop cashier project, now in it there is a module that can add items. the plan is that the user (admin) will input the items, prices and stocks that are stored in the ListBarang struct variable then stored in a file... but when running, the program actually stops after the user inputs the stock and the file remains empty... does anyone know how to save it in a file and later it can be accessed again to add or delete per unit item?
Chat Boss
AL sent a code, it has been re-uploaded as a file
AL
this is the code i tried
Timm
I'm learning C too
how to write c program
An
why not use memcpy?
It doesn't copy the structures properly
klimi
It doesn't copy the structures properly
what structure? it's just C array no?
klimi
An array of structures
then std::move them all if they are complex structures no?
klimi
oh you wanted to copy... well, if they are copy-able you can just copy them
Guillermo
this is the code i tried
You should run it into a debugger
Guillermo
An array of structures
you can copy an array of data structures with memcpy anyway, just pass the source address, the destination addres and the size (which usually is sizeof(data structure) * number of elements)
Guillermo
let say you have something like this: struct { vec2 position; Texture *pTexture; } GameObject; GameObject actors[100]; GameObject temp[100]; memcpy(temp, actors, sizeof(GameObject) * 100);
Albatross
Hi, I'm having trouble compiling a C++ code in my command prompt. I have installed Microsoft Visual Studio 2022 and added the path to the environment variables. I am running the 'cl hello.cpp' command in the same directory as my source code which is a simple 'Hello World' program. However, I'm encountering the following error: 'hello.cpp(1): fatal error C1034: iostream: no include path set.' I'm not sure why I'm getting this error or how to solve it. Can you please guide me on how to resolve this issue?
Guillermo
Just use the command prompt provided by your Visual Studio IDE
Albatross
how to open that?
Guillermo
Look for it in your windows
Albatross
but bro, I want to compile my code from anywhere in my pc like python how we are compiling like that how to do that here what is the right comment bro
Guillermo
I understand you, but you will need to do more settings apart of adding the path to your environemt variables
Guillermo
thats why most ppl uses the command prompt provided by your VS 2022
Guillermo
won't there be a problem with the pointers?
Nope, unless you are doing things with memory aligment and packaging
Albatross
this path I add already C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64
klimi
Nope, unless you are doing things with memory aligment and packaging
but the pointers will be pointing to the old memory no?
Guillermo
this path I add already C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64
yes, but you need more things, I mean, set up environemt variables add more paths, etc ...
Guillermo
but the pointers will be pointing to the old memory no?
the memory neveer disappears unless you are declaring in the local scope of the method/function
Guillermo
i'm ready to do that all
Ok, execute the command I told you before and start copying things from that command line to your environemt variables
klimi
the memory neveer disappears unless you are declaring in the local scope of the method/function
yeah but if i have linked list and i copy the memory, there will be poiting that will be poiting to the old memory, when i modify this, i will be destroying my original linked list and not modifying the copy
Guillermo
I mean, execute the command tool, and type 'set'
Guillermo
and copy everything to your environemt variables
Guillermo
anyway, for linked lists it shouldn't be a problem, but instead of using memcpy, you will need to travel the full array
Albatross
I mean, execute the command tool, and type 'set'
this one I don't understand well can you say it more clearly
Albatross
when I work with minGW that time I add only minGW bin folder path it's worked well on that time
Guillermo
this one I don't understand well can you say it more clearly
1º - Command Prompt for VS 2022 2º - type 'set' Then, copy everything you get into your environment variables
Guillermo
do you understand now?
klimi
well, you didn't say anything about linked lists, you said about arrays of data strcutres
and that datastructure can use pointers, that was my point, the OP didn't provide more info ¯\_(ツ)_/¯
Guillermo
the problem is not the data structure, is the memory allocator
Guillermo
I mean, when you define an array of data structures, all the memory is allocated once afther the other
Guillermo
with memory allocation, you depends on the valure given by malloc()
Guillermo
one trick is to declare one array of some elements with malloc so you can make copies the same way you are doing with datra structures ¿Do you understand?
Guillermo
Something like: LinkedList *GameObjects = LinekdList_Init(100);
Danya🔥
Specifically CMake
Guillermo
after that, you could use memcpy the same way you are doing with arrays, but be aware that, you can do it just because the memory is allocated for the whole block
Danya🔥
Specifically CMake
It'll find all the necessary things for you
Albatross
do you understand now?
it's giving lots of path and text so I confuse lot
Guillermo
yes, that's why I told you to use the command tool provided by VS 2022
Albatross
Learn how to use build systems
what is the use of this one bro,
Guillermo
you could do the thing Denya told you
Guillermo
yes I use that
well done!
Albatross
well done!
compile is the first step it's also very verry hard in cpp i'm thinking like this
Albatross
missing minGW exe ahaaaha
Guillermo
well, you can install it on your system
Guillermo
there is cygwin too altought I don't know the difference between both of them
Guillermo
good luck dude!
Albatross
well, you can install it on your system
now exe for minGW is not available in the internet this is the problem
Anonymous
now exe for minGW is not available in the internet this is the problem
Since mingw is not available,you can install wsl instead
Anonymous
Windows subsystem for linux
Albatross
nooo I am using windows
Anonymous
nooo I am using windows
Wsl is a linux subsystem for windows
KRISHNA
Windows subsystem for linux
Download Virtual box for Linux
Albatross
i think this microsoft visual 2022 can compile cpp code but need to do some other step also like adding more path to environment
Anonymous
nooo I am using windows
You will see how things work once you install it
Albatross
i install msys2 it's also not well for me bro
Albatross
Hello! If you are using Microsoft Visual Studio 2022 to compile your C++ code, could you please share your process? Specifically, I'm interested in how to compile C++ code from anywhere on the PC using the command prompt, similar to how we run Python code. I would really appreciate any guidance on this matter.