Anonymous
Enables every possible warning
布丁
(then go rust
Anonymous
(then go rust
Not the place for this
布丁
(error on everything unless unsafe
布丁
Not the place for this
Just a joke🤣
Anonymous
if you can explain with more details that would be better because I think I'm confused with what you are saying
1) what you were doing is undefined behaviour. why your output and the video output was different might be due to something else. fix undefined behaviour first. 2) since the behaviours aren't defined, compilers won't produce an error message for you. 3) however, you can add some compiler flags that will try to warn you about some undefined behaviours in your code. keep in mind that the flags can have both false positives and false negatives (more likely).
Anonymous
good code is DEFINED as good, error producing code is DEFINED as bad. casting to different pointer type and then using the pointer to access the underlying object is undefined
فاطمهَ 💛
Did you mean int **p=&p_arr?
what's the difference?
Anonymous
what's the difference?
When you're talking p_arr
Anonymous
You're talking about the address of the first element of p_arr
Anonymous
So int *a = p_arr
Anonymous
When you're talking about &p_arr
Anonymous
You're talking of the address where p_arr is stored
Anonymous
But since p_arr itself is a pointer to the first element &p_arr is a pointer to a pointer
Anonymous
So int **a = &p_arr
Anonymous
Arrays are basically pointers
Anonymous
When I say p_arr[0] I'm actually saying *(p_arr + 0)
Anonymous
But you know that number + 0 = number
Anonymous
If you remove the 0
Anonymous
p_arr[0] becomes p_arr
Anonymous
&p_arr means you're referring to the address where the address of the first element is stored
Anonymous
So to access &p_arr you need a pointer to a pointer
Anonymous
What you probably want is
Anonymous
int *a = p_arr as already suggested by @chandradeepdey
فاطمهَ 💛
Anonymous
got it but I meant just one *
Then remove the &
Anonymous
If you add & it becomes a pointer to a pointer
Anonymous
got it but I meant just one *
Also note that *p + *q is undefined behavior
Anonymous
Since *p and *q are memory locations they will change every time the program is executed
Anonymous
Also of note is that an integer pointer is 8 bytes but an integer is 4 bytes on most machines
Anonymous
This means you trigger a second undefined behavior
Anonymous
Memory addresses are always 64-bit so they need to always be 8 bytes. You're pointing to an 8 byte memory location with a data type that defines a 4 byte capacity. The output will always be undefined and the memory address will always be wrong
Anonymous
Also comparing 2 memory addresses is undefined behavior You can't do &a > &b Adding/subtracting/any mathematical operation is undefined You can't do &a * &b
Anonymous
oh thank you for all these useful informations very much
No it just proves you're not paying attention while learning
فاطمهَ 💛
a very new one
فاطمهَ 💛
I don't think it's a nice way to say welcome..
Wisenky
how to display jpg on console with c++
Asdew
You want the console window to display an image?
Asdew
Libcaca should work for that.
Emir
#include <stdio.h> #include <stdlib.h> int main() { char buffer[128]; FILE * dosya = fopen("a.txt", "r+"); int len = fread(buffer, 128, 1, dosya); printf("%d", len); }
Emir
Here is my txt file
Đỗ
since i have memory allocate in class so i have to overload assignment operator but But besides assign one by one, is there any better way?
you can use some type of old c++ function; memset -> memcpy, but use at risk if you want, you can use some util from STL lib, such as std::advance, to cope with vector of same object
Đỗ
fread return 0, why is that?
1. fread() has the option param to hold error code return. Try to stumble and probe this error value 2. I think for the sake of security, you shouldn't post any raw file in here. Some guy may be capture it and redistribute it for malicious purpose
Ajay
woh! first time saw the cin with the insertion operator.
Onan
Hi👋
Ajay
Nothing is strange about it
can you link to somwhere where these have been explained to be used in tandem?
Anonymous
Ctrl + shift + Delete ?????
Anonymous
C++ app dalo please
Anonymous
Ctrl + shift + Delete ?????
Is there any one who can tell about this?
01000001011011010100000101101110
Callof
I am bigginer so anybody help me that how to start programming language
Anonymous
Please upload a c++ app
01000001011011010100000101101110
Please upload a c++ app
search on google, you'll find it
01000001011011010100000101101110
You what
I think he means c++ compiler
Anonymous
You what
Ya I want that app
Callof
Check out "Online Compiler - Code on Mobile" https://play.google.com/store/apps/details?id=app.compiler
Serenity
Switch $$$ 80 Nic $$$ 120
Serenity
How can I split the names and the numbers into two different strings using strtok ?
Serenity
After the number , there are many whitespaces..
Anonymous
Did you mean int **p=&p_arr?
this is undefined behaviour as well. &p_arr is of type int (*)[4], which is not the same as int **.
Anonymous
Also note that *p + *q is undefined behavior
no. *p + *q just adds two integers
Whistleblower
according to the videos from YouTube the last line has to be 2, 5 but the output says it's 7,5 so what did I miss?
There is a difference in p+1 and ++p or p++, ++p can also be written as p=p+1 whereas p+1 is not storing the location back in p. So, when in next printf we are getting 7 instead of 2 which is actually correct .
Whistleblower
Read pointer arithmetic to clear your doubts and get clarity
Anonymous
Guys I have a C/C++ test tomorrow
Anonymous
Can anyone of you help??
Nameful
Can anyone of you help??
what's your question?
Anmol
https://del.dog/exaghafusu.txt
Anmol
https://del.dog/exaghafusu.txt
Should I be using a std::move on line 3?