Anonymous
Wht does void do?
Dima
universal pointer smells like polymorphism in c
Dima
😹😹
Dima
/warn command abuse
Dima
Wojak
Hello
Wojak
How can we pass one parameter in main for a function having two parameters and still expect the code to work fine.
Wojak
How can we pass one parameter in main for a function having two parameters and still expect the code to work fine.
Eg- void sum (int a,int b, int c) For sum of three numbers and doing sum of just two numbers in main
Wojak
I hope my question is clear
Wojak
This is an example to make you understand what I'm trying to ask
Dima
Eg- void sum (int a,int b, int c) For sum of three numbers and doing sum of just two numbers in main
do you want to return ‘int c’ as a value? do you want to set a default value to ‘int c’ ? I don’t get it
Dima
or you want to call a function with only two parameters?
Wojak
do you want to return ‘int c’ as a value? do you want to set a default value to ‘int c’ ? I don’t get it
Function- Void sum(int a,int b,int c) In main- See If User Want to do sum of 2 Number(passed as argument) the function will work for 2 numbers. If user want to do sum of 3 Numbers(passed as argument) function will work for 3 number
Dima
ohh
Wojak
I hope you understand what I'm asking I can't explain in more detail
Wojak
😅
Dima
yeah, use a pointer void sum(int a, int b, int* c = NULL) { return a + b + (c != NULL ? *c : 0) }
Dima
I don’t know if this is valid for older versions of C
Dima
Fuck this bad
still better than modern c++
Dima
😌
Anonymous
I don’t know if this is valid for older versions of C
It's not valid in ANY version of C
Dima
well you got the point
Dima
use pointers
Anonymous
Don't do
Wojak
Don't do
Ok Then what else?
Anonymous
do functions sum2, sum3, sum4 etc
Dima
do functions sum2, sum3, sum4 etc
it looks like ultra retarded
Dima
sum5, sum6, sum8
Dima
just pass an array as parameter LOL (jk)
Anonymous
Dima
do functions sum2, sum3, sum4 etc
what if he has variable input parameter count
Wojak
Thanks @Neko_cpp
Dima
kinda true
Anonymous
And use dynamically allocated arrays
Anonymous
Or VLA since it's C😜
Anonymous
Eg- void sum (int a,int b, int c) For sum of three numbers and doing sum of just two numbers in main
this is how functions like printf() and scanf() work (not exactly, but almost)
Dima
https://en.cppreference.com/w/c/variadic
holy crap I didn’t even think of that
Dima
nice
Anonymous
Anonymous
nonononono. these are not nice
Dima
I mean I’ve totally forgotten about this feature
Anonymous
Eg- void sum (int a,int b, int c) For sum of three numbers and doing sum of just two numbers in main
just in case the nonononos weren't clear enough, don't use them. there is type safety, and then there is the exact opposite ....
Nik0
I have some question about C
Nik0
Can i send the code here?
Dima
Can i send the code here?
If it’s long enough use pastebin or something
Nik0
Not really
Nik0
Wait
Nik0
Ok there
Nik0
Oh i can't send the link
Anonymous
Then you can do a __clang_error_if() idk
M
Hello guys, there is something weird with my program. I'd appreciate it if you take a look and advise me. It's a substitution cipher program, where you need to give the key (26 non-repeating alphabetic characters and case insensitive). First I check the key then proceed with ciphering the text. But when using capital letters in the input, my program prints the said symbol twice. https://pastebin.com/9L3CHRus
Pablo
/report
/report
Pablo
Sorry, my mistake
Anonymous
Hello everyone
Anonymous
Thanks man
Anonymous
I'm a beginner and I'm Brazilian
Anonymous
Nice to meet you, guys
Anonymous
There are a lot time that I tryna learn C++... I hope this time I could do it
Anonymous
I wana ask, where I can practice C to exercise everyday?
Manish
Hi , I have a method which have parameter uint64_t& like below fooMethod(uint64_t & number); I have to a variabl of uint32_t unit32_t input; How to do type conversion to pass input into fooMethod without using another variable?
Vlad
const& will do
Or universal ref
Manish
const& will do
Please provide full syntax.
Vlad
Please provide full syntax.
void foo(const uint64_t& a) { .... }
Vlad
Or void foo(uint64_t&& a) { }
Manish
void foo(const uint64_t& a) { .... }
Thanks:). How to call it when I have uint32_t input;
Manish
Please provide full syntax.
I have to modify "a", so I can't make them const.Can we do things wihout using universal ref?
V01D
Sorry, my mistake
Lol, it's cool.
Anonymous
Nothing C++ is not a language for fast learning