coal
And when we define variable, it has this data before initialization.
yes, then this unused memory is now of value, even if its not defined by your program yet
Lamar
wouldn't you be better off asking to friends or people that you know irl and near your location
The ppl I know don't know anything about laptops. They just buy what's showing on stand in PC Richard and son
coal
garbage is not garbage if its free to use, that's what i mean
Lamar
or buying online, there's amazon and ebay
I know that but I'm having a problem not to think like a coder if you understand what I mean
coal
lol
coal
try Facebook marketplace or something idk, this is likely the last group that would be of use
coal
you're welcome
Leovan
yes, then this unused memory is now of value, even if its not defined by your program yet
So why when we cout heap's free to use (m[6]) is empty, not previous value
Anonymous
Anyone help for making cards game
coal
So why when we cout heap's free to use (m[6]) is empty, not previous value
that's mere coincidence, the values outside of the array scope produce undefined behavior
coal
try with something like m[73290]
coal
and it (probably) wont be empty
Leovan
Oh
Leovan
Segmentation fault, now nice
Leovan
Thanks, now i understand
coal
Thanks, now i understand
you're welcome
coal
??
it depends in many many many many many many many factors
coal
what kind of card game, what rules, what engine / graphic library, what os, which lang, what libraries are you using/plan to use
coal
make the game yourself and when you encounter an issue you can ask for guidance
Leovan
you're welcome
BTW, returning to an uninitialized variable, the most common output is 0, is this a coincidence or depends on compiler? I understand this is undefined behaviour.
coal
its a coincidence always
coal
but it outputs 0 because that certain address holds a literal 00000000... n
Leovan
Interesting
RITESH
[10:40 AM] Harshit Shukla (Guest) std::array<col, 6>table; //create a table with 5 columns of col type introw_number=0; // std::string pid, name, gender, age, fare; std::stringrow[6]; while(!file.eof()){​​​​​​​​​ for(intcount=0;count<5;count++) {​​​​​​​​​ getline(file, row[count], ','); table.at(count)[row_number]=row[count]; }​​​​​​​​​ getline(file, row[5], '\n'); table.at(5)[row_number]=row[5]; row_number++; }​​​​​​​​​ DisplayColumn(table[1]); ​[10:41 AM] Harshit Shukla (Guest) voidDisplayColumn(std::array<std::string, 891>&col) {​​​​​​​​​ for( autovalue :col ){​​​​​​​​​ std::cout<<value<<"\n"; }​​​​​​​​​ }​​​​​​​​​ any help what is happening in this program
Dima
try to find it out yourself first
Anas
hello i wanna ask you how can i draw a star pattern
Egro
Guys!!!
Egro
I build my first c++ project
Egro
It’s a file management system to take notes. Input from the users and save it… omg I am feeling so much joy now. Took me weeks and weeks and I finally competed it !!
Ahany
Hello hello ,, anyone here really familiar with ( structs, pointers and linked lists can help me debug a bit in my assignment)
Ahany
I can share screen on discord
Ahany
Cause the code is really long
coal
you need to wrap the help you need in a question
coal
like, dont ask "someone can help with structs", but rather "how can i make a struct with pointers that refer to other data"
coal
or something like that, so someone that doesnt have much time and goes by the chat will help you quickly
Anonymous
Yeah, I use
Do you share me your C4droid apk
Rajesh
Hi anyone help me for json file read and write in c++
Rajesh
Facing directive problems
Rajesh
np
Hi bro best file for json read write in cpp
Rajesh
Need to parse json content
coal
Need to parse json content
use a state machine
coal
a json parser is probs the most basic parser to implement
Rajesh
use a state machine
Need to read the json objects and return as a string
coal
json objects arent objects until you deserialize them
coal
what do you want to return, string values of the json?
Rajesh
what do you want to return, string values of the json?
Parse the values of keys as string/integer
Rajesh
Like parsing in java
Anonymous
hi, what ebook you recommend for the exam ( CPA – C++ Certified Associate Programmer Certification )
Rajesh
Anyone help me for json parsing in c++
Alishba
Is there any way contents of a file can be cleared fully in c++
coal
coal
lol
Anonymous
#include <stdio.h> main(){ int i, x, total; total=1; printf("ENTER ODD NUMBER BETWEEN 500 and 1000"); scanf("%d",&x); if(x%2==0||x<500||x>1000){ printf("INVALID"); } else{ for (i=x;i>0;i--){ total=total*i; } printf("THE FACTORIAL IS %d",total); } }
Anonymous
I want to print factorial of the number
Anonymous
But it print 0
Anonymous
It is defined in line 3
Talula
Another reason is your total is overflowing... 513 * 512 * 511 .... etc... is a very large number cannot be handled by C directly.
Hsn
Float or include uint128?
Rajesh
Anybody help me Getting undefined reference error in json parsing in c++
Vishal
Tell me best c++ book
Vishal
And OOPs concepts clear book
Vishal
Names
Rshtan
Give me a programs websites for c++ oop😊
Ominitric
Cpp
Anonymous
C++ is basically C with classes
It originally was but evolved beyond that
Anonymous
garbage is when you initialize a new pointer and dont delete it when you're done using it
Garbage varies from OS to OS on few there are hardened runtimes which zero memory where possible during allocation, free, and resource reclaim in order to prevent attacks that take advantage of left over memory that could hold secrets of some kind that they should not know about, say passwords left over in memory On most, memory will be left uninitialized as it is reused by programs, uninitialized memory may contain garbage This garbage data may have been useful data for a previous program that was running (P1 exits which causes 0x56 to be released back to the system, P2 allocates the free 0x56) This garbage data may have also been useful data for a running program that has since freed that memory (P1 frees 0x56, P2 allocates the free 0x56) Do note that most garbage is from malloc/new since they recycle freed memory globally by all programs In most cases when a program starts up it will be allocated memory for its main stack eg the main thread, usually a very generous 8 MB depending on OS and thread implementation normal threads will have a much smaller stack unless explicitly requested a larger stack upon thread creation, as they do not normally need to run a full program and manage lots of stack variables and stuff since all that is shared with the main thread via address space sharing (differs from OS to OS) this memory may or may not have been previously used by another program that has since freed that memory Eg on a freshly booted system it is likely the entire RAM is filled with zeros and most new programs will receive zeroed memory until recycling kicks in (assuming when RAM powers off its entire contents is effectively zeroed due to it not retaining any data) Tho the kernel may also unintentionally cause new programs to get garbage when fresh booted even if no programs have started yet and it is only the kernel init process running (the kernel itself (or sysd, can't remember) is usually init with pid 0, OS dependant tho) Also note that if a process or libc implementation zeros it's allocated memory address 0x56 before freeing it then another program allocating the same memory address will receive zeroed memory since 0x56 was zeroed before it was freed Tho this zeroing of memory should NOT be relied on and callers should use calloc to unsure zerod memory if memory will be partially overridden (calloc is usually much faster than malloc + memset) or malloc/new if all memory will be FULLY overwritten and not read before it is overwritten
coal
Garbage varies from OS to OS on few there are hardened runtimes which zero memory where possible during allocation, free, and resource reclaim in order to prevent attacks that take advantage of left over memory that could hold secrets of some kind that they should not know about, say passwords left over in memory On most, memory will be left uninitialized as it is reused by programs, uninitialized memory may contain garbage This garbage data may have been useful data for a previous program that was running (P1 exits which causes 0x56 to be released back to the system, P2 allocates the free 0x56) This garbage data may have also been useful data for a running program that has since freed that memory (P1 frees 0x56, P2 allocates the free 0x56) Do note that most garbage is from malloc/new since they recycle freed memory globally by all programs In most cases when a program starts up it will be allocated memory for its main stack eg the main thread, usually a very generous 8 MB depending on OS and thread implementation normal threads will have a much smaller stack unless explicitly requested a larger stack upon thread creation, as they do not normally need to run a full program and manage lots of stack variables and stuff since all that is shared with the main thread via address space sharing (differs from OS to OS) this memory may or may not have been previously used by another program that has since freed that memory Eg on a freshly booted system it is likely the entire RAM is filled with zeros and most new programs will receive zeroed memory until recycling kicks in (assuming when RAM powers off its entire contents is effectively zeroed due to it not retaining any data) Tho the kernel may also unintentionally cause new programs to get garbage when fresh booted even if no programs have started yet and it is only the kernel init process running (the kernel itself (or sysd, can't remember) is usually init with pid 0, OS dependant tho) Also note that if a process or libc implementation zeros it's allocated memory address 0x56 before freeing it then another program allocating the same memory address will receive zeroed memory since 0x56 was zeroed before it was freed Tho this zeroing of memory should NOT be relied on and callers should use calloc to unsure zerod memory if memory will be partially overridden (calloc is usually much faster than malloc + memset) or malloc/new if all memory will be FULLY overwritten and not read before it is overwritten
yeah everything here was discussed in following messages of the conversation