0
Why does it always skips this if statement?
8 Antworten
+ 1
don't know much about cpp so I don't know if you have changed 'n' to 1 but as long as n = 0 it will also be the same as false such as 1 is equal to true in if statements
+ 1
at the first run n is nullptr, as far as i know it'll be treated as false in if statement
+ 1
You have to pass a pointer to edit a var from inside a function... Then if you have to edit an int, you have to pass an int*. If you have to edit an int* you have to pass an int** ... Try to see this code
https://code.sololearn.com/cng46f40L7ne/?ref=app
0
if you want the if loop to be done if n = 0 you could do if(n==0) or if(!n)
0
if n is a null pointer (nullptr or NULL) then n will be valutated false as boolean
0
Krow, but it's always nullptr, i don't know why
0
Oleg Storm Its normal that its always nullptr because the "if" block never run and though if it would run, you have to modify "n" insided main from the function (with pointer to pointer or reference)
0
Krow, like if i create a new Node, this node will point to NULL?