alessandro
i have one file, it has like 400 names, which is the best way to manage it in memory? I mean if I can manage it in one program without lose performance?
Anonymous
Can you tell me how to create a profile account for a game like minesweeper?
Anonymous
In c
alessandro
idk
Zel
@Alex0162080 Best way is to not have 400 copies. Load it once and use pointers to acess it.
alessandro
Zel
@burn Slightly, but that's like the text book case use for pointers, where as if you load the file 400 times it will be slow, memory intensive and possibly cuase dara loss if you are doing write operations.
Zel
Now on the flipside if you have 400 copies of exactly the same file on disk, you may want to optimize how you are using data.
Uliana
Please explain, how to delete structure components, while working with files, cause I think I’m doing all right, but it doesn’t work(C language)
Dima
use fclose() and null its file pointer
Uliana
I use them) but nothing happens
Dima
you better post the code using pastebin
Uliana
I’m sorry, but what is pastebin?😳
Pavel
Ибраги́м
https://www.youtube.com/watch?v=xBAduq0RGes
Ибраги́м
Deepak Chaurasia
Hay like i am trying to make a char type array of length 100 so is it possible to check on how much memory occupied
Like char arr[100]
I enter the string "the "
So it can return 3 byte occupied
klimi
neovstan
Deepak Chaurasia
strlen
Not like that, like this is boy so i need to print something like that
This
is
Boy
Deepak Chaurasia
So i need index of all words to print in new line from a string
Anonymous
Do you have the code for dividing two long numbers?
Deepak Chaurasia
Do you mean to factorial?
Anupam2.7
Uliana
Uliana
https://pastebin.com/MYmZrLw0
shriman_deepak
And i see in line 69, if u are trying to delete the data which is already there in the file then u should use == 1 instead of 0 coz.. 0 means false and 1 means true.
Uliana
Uliana
Uliana
and I can’t delete
shriman_deepak
well send me the text file u are working on
.
Which one is better? Mingw or cygwin?
.
I'm a newbie
Aman
Chat Boss
Aurora YxY sent a code, it has been re-uploaded as a file
Aurora
prompt segment fault
Aurora
AllocPageMem is allocate shared memory function by mmap
alessandro
I'm a newbie
If you can use windows you could begin with visuale studio community, it include c++ compiler....
MᏫᎻᎯᎷᎷᎬᎠ
I just found out there is a feature called function-try-block in C++, wow this languages never cease to surprise me
Anyway I'm checking it in cppreference
It states:
Reaching the end of a catch clause for a function-try-block on a destructor also automatically rethrows the current exception as if by throw;, but a return statement is allowed.
What does this mean, the last sentence
I know it's not possible return something from the destructor
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Why function-try-block is used rarely, I think It's great, is there any drawbacks?
Anonymous
Why function-try-block is used rarely, I think It's great, is there any drawbacks?
It is just like any other feature. Has its uses. It is used where it ought to by people who know about it. Mostly used to catch exceptions in the member initializer list of a constructor. Seldom used around a destructor unless you have a custom allocator and you allocate specific chunks of an instance of a specific type. It is not used outside of these two use cases.
DaviChan
Why function-try-block is used rarely, I think It's great, is there any drawbacks?
- Its "modern". Many code bases are still using old code pre C++11 and it takes time to adapt.
Also checking error codes does also work well. In C++ we have multiple ways to deal with exceptions, so this one is not always preferred.
- comes with runtime overhead.
- disturbes control flow, might make code flow hard to follow
But yes, it is a great feature to have and for some projects i even abused them to an extend because its easy to work with.
DaviChan
For example at our comapny we use C++20, we still don't use try blocks. Not sure why. But you can clearly tell code that was written recently from old code appart. We do still have code from unix times where functions that really should be void return a bool or int as a status code that no one ever checks
Ludovic 'Archivist'
DaviChan
DaviChan
But yeah... i never used try catch until C++11... why are they so unpopular 😅🤔
DaviChan
I mean java and python guys use it all the time
...
DaviChan
will look into that later :)
...
"exceptions" under modern OS's can get very cumbersome, look at MSVC's SEH extensions for example, absolute chaos
Totti
How to create a structure type
DaviChan
DaviChan
you can use a typedef or write it like this: struct{/*...*/} a; to be able to use it without the "struct"
Gabriel
struct some_data { int x; int y; };
DaviChan
Yeah the comment looks cute right 👌😂
...
Thanks, i use this tool daily ^^
I meant the code that this links to, you can see a lot of unnecesarry calls & GCC's optimizer esentially giving up on optimizing away the function call
Gabriel
You could try something like typedef struct vector_region { float x, y, z; } vector_t; And uses the "vector_t" as type when defining the variable
Totti
Thank you guys
Ludovic 'Archivist'
But yeah... i never used try catch until C++11... why are they so unpopular 😅🤔
Because while exceptions are (almost) free if they are not thrown, if thrown, the stack unwinding is very very expensive.
They should be kept for very exceptional/dramatic errors and not for what I would describe as common errors (errors that may happen more than 100 times per second are common enough in my book, errors that may happen once a second at most are not)
Anonymous
Can anyone suggest best c++ video playlist on YouTube.
Deepak Chaurasia
What are you trying to do
Anonymous
I got an exercise in c language, asks for making the "mine swipper" game anyone here can help me?
Anonymous
The problem is not making the game it self , I got the c files and header but how to complete it....
So if anyone can help I Ppreciated
Ar
const char* shader = “#version 330 core\n”
“layout (location = 0) in vec3 aPos;\n”
“void main()\n”
Ar
Why can pointer be assigned certain strings?
touhou
Why can pointer be assigned certain strings?
String here is just an array of characters.
When you do something like that above statement.
The pointer will just point to the first character in the array.
i.e addr of the first element is stored in the pointer.
But you cannot modify that string tho.
touhou
Or I would even say, don't even consider it as an array.
It's just characters in continuous block of memory.
Ar
touhou
touhou
To make it more clear to read or whatever.