Anonymous
Enables every possible warning
布丁
(then go rust
布丁
(error on everything unless unsafe
布丁
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
فاطمهَ 💛
Anonymous
فاطمهَ 💛
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
Anonymous
If you add & it becomes a pointer to a pointer
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
فاطمهَ 💛
Dima
Anonymous
فاطمهَ 💛
فاطمهَ 💛
a very new one
فاطمهَ 💛
I don't think it's a nice way to say welcome..
Dima
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
Emir
Here is my txt file
Đỗ
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
Anonymous
Ajay
woh! first time saw the cin with the insertion operator.
Onan
Hi👋
Anonymous
Anonymous
Ctrl + shift + Delete ?????
Anonymous
C++ app dalo please
01000001011011010100000101101110
Callof
I am bigginer so anybody help me that how to start programming language
Anonymous
Anonymous
Please upload a c++ app
Anonymous
01000001011011010100000101101110
You what
I think he means c++ compiler
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
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??
Anmol
https://del.dog/exaghafusu.txt