Talula
phones are not made to code on =-=
Better to use online compiler if you want to use it on phone.
Ehsan
PCs/Laptops are 🙂
Maybe tablets too, if u have a keyboard; but you can’t really make a development environment with the apps provided :(
Talula
https://www.onlinegdb.com/online_c_compiler
\Device\NUL
Yes
Really ?
xypher
Really ?
Ohh! sorry my bad nah
xypher
Im in linux btw🤣
xypher
Suka
Is Dev C is still in active development ?
i believe it is still in active development. https://www.embarcadero.com/free-tools/dev-cpp
\Device\NUL
i believe it is still in active development. https://www.embarcadero.com/free-tools/dev-cpp
Welp, the wikipedia said the official Dev C++ app hasn't been update since 2005
Suka
Welp, the wikipedia said the official Dev C++ app hasn't been update since 2005
hehe. perhaps wiki refers to original dev cpp (before embarcado version?)
\Device\NUL
hehe. perhaps wiki refers to original dev cpp (before embarcado version?)
I think yes, i readed that Embarcado version is forked from the original
AmR
I need CMake help please ?
AmR
I try this from 3 days
Leovan
I'm studying dynamic memory in C\C++ and don't understand that: I'm declare char array of 5 elements, it doesn't matter in C or C++ style. 1) Why I can get access over the memory area (for example m[10]) without errors/warnings? Shouldn't the OS keep track of this? 2) Why m[6] (and another more than array size) value is empty? Shouldn't there be garbage then? Maybe this is malloc's protection mechanism? Sorry for my english, thanks for your patience. #include <iostream> #include <cstdlib> int main() { char * m = (char *)malloc(sizeof(char)*5); // char * m = new char[5]; for (int i = 0; i < 5; ++i) m[i] = 'H'; for (int i = 0; i < 10; ++i) std::cout << m[i]; std::cout << ';' << std::endl; // HHHHH; free(m); // delete [] m; return 0; }
coal
you dont need to cast it to char*
coal
is redundant cause the void pointer is already safely promoted to any other pointer type
coal
m[6] is not truly empty, it's just you trying to access memory outside of the scope that malloc created for you
coal
m is a literal pointer, so it covers basically the entirety of your virtual memory, and you can sum or subtract as much as you wish from the address
Leovan
you dont need to cast it to char*
Interesting, the teacher of the course drew attention on this.
coal
m[6] is syntactic sugar to sum to the pointer that malloc returns
coal
Interesting, the teacher of the course drew attention on this.
the teacher told you to cast it like that?
coal
its unnecessary since you're in C++
coal
so its protection malloc's mechanism? Why doesnt garbage in m[6]?
m[6] could be a literal array next to the one you're trying to access
Leovan
not C
All okey than, he is said about that in the C context
coal
if for some reason, in the memory there were two consecutive arrays of size 5, called "a" and "b"
coal
"a[6]" would be equivalent to "b[0]"
The Shadow Monarch
#include<stdio.h> #include<math.h> int main() { double x1; //Abscissa of point A double y1; //Ordinate of point A double x2; //Abscissa of point B double y2; //Ordinate of point B printf("Input the coordinates of point A "); scanf("%f %f \n", &x1, &y1); printf("Input the coordinates of point B "); scanf("%f %f \n", &x2, &y2); double x=x2-x1; double X=x*x; double y=y2-y1; double Y=y*y; double Z=X-Y; printf("Distance between the two points is : %f \n", sqrtf(Z)); return 0; }
coal
because it's a literal pointer, therefore you can access any other value with it
The Shadow Monarch
I m gettiin a error 1.#INF00
Leovan
because it's a literal pointer, therefore you can access any other value with it
Okey, but I still dont understand why value is empty, is this protection?
Leovan
because there's nothing there yet
what about garbage which remained from other programs in the heap,
Leovan
like access to uninizialized variable
coal
are you currently in linux btw?
Leovan
yes
coal
like access to uninizialized variable
uninitialized variables cause undefined behavior
coal
but its not illegal to access to them
Leovan
yes
coal
and there's no garbage to collect
coal
you're confusing the memory addresses that you dont manage with "garbage"
coal
garbage is when you initialize a new pointer and dont delete it when you're done using it
Leovan
but int a; std::cout << a; will print garbage which at the address of the variable
Leovan
garbage for me is values which is in memory after running other programs and no longer used
coal
but int a; std::cout << a; will print garbage which at the address of the variable
no, it prints whatever data was at that particular memory location
Anonymous
How to write entered date of birth by the user to CSV file ?
Anonymous
printf("Enter Date of Birth(DD/MM/YYY): "); scanf("%d/%d/%d", &day,&mon,&year);
Leovan
no, it prints whatever data was at that particular memory location
hm, but as far as i know: let's take memory cell (for example with the address 0x1a7c78b5) - 1 byte. It was used by other programs before and now it contains data which they no longer need (10110111 for example). Now we in our new program declare (but not initialize) variable and it got the same address (0x1a7c78b5) which still contain this data - 10110111 (garbage) until we initialize it.
coal
the garbage collector doesnt collect random garbage at some points of memory that are out of your program scope
coal
that would also be a segmentation fault
coal
the term garbage has a concept in CS already and you're defining a different concept for it
Leovan
garbage is exclusive to what your program produces and doesn't use
Okey, maybe I called it wrong. Its of course different terms
coal
yes, your program is not responsible for other program's garbage
coal
in your context, its not garbage until you use and throw it
coal
uninitialized variables are not garbage because they're not being used at all
Leovan
uninitialized variables are not garbage because they're not being used at all
I mean something what left in the RAM from other programs
Leovan
And they dont need it more
coal
I mean something what left in the RAM from other programs
that's not garbage until your program allocates it
coal
data that is not allocated by your program is not being used therefore its not garbage
Leovan
But its left in RAM and no one need it
coal
garbage is the memory which was allocated by the program, but is no longer referenced
coal
But its left in RAM and no one need it
yeah that means its free to use
coal
even if its not empty
coal
it would be unefficient to set all that memory to 0 just because its no longer used
coal
when its no longer used, even if it has data the memory is free
coal
and then when you allocate it, its now being used by your program
coal
also i would like to mention that garbage is only considered garbage within your program scope, because its memory that is restricting your own program from allocating it because it was being referenced by some lost pointer
Lamar
Hey guys I know this is a group to discuss and help with C++ but I'm looking for a laptop for School , real estate , crypto , photos general purposes. I my friend has a $500 budget and 8gb of RAM and SSD is necessary. Sorry for the off topic
Leovan
yeah that means its free to use
And when we define variable, it has this data before initialization.
coal
or buying online, there's amazon and ebay
coal
in this group you're likely a few thousand kilometers away from everyone else