Alex
and this one is compiled too void fn(char ss[]) { } int main() { char s[60]; fn(s); }
Anonymous
can`t understand your issue. it is compiled void fn(char ss[40]) { } int main() { char s[40]; fn(s); }
s turns into a pointer and the 40 in ss[40] is just ignored by the compiler. ss[] is *ss. > "Is it ok to pass a string to a function as an array" you can't pass it as array if you do this. you have to pass it as a pointer. the only way to pass it as an array is to use a pointer to array.
Alex
so you can use this function with arrays of different lengths
Anonymous
yes, but I can`t see the practical problem
:/ he asked if it is ok to pass as array instead of pointer. i said you can't pass as array, you have to pass as pointer since that is automatic.
Alex
you wrote this: you can pass it as an array, but then your function can't work with arrays of different lengths
Alex
you can work with arrays of different length. I can`t see any problem
Anonymous
you wrote this: you can pass it as an array, but then your function can't work with arrays of different lengths
ye i meant—you can pass it as an array if you REALLY want to, but you will have to do this X absurd thing.
Alex
ok, for practice I suppose its ok to use void fn(char s[])
Anonymous
and this one is compiled too void fn(char ss[]) { } int main() { char s[60]; fn(s); }
and here. you pass a pointer, not an array. you cannot do sizeof(ss) inside fn
Anonymous
that was my point. you can do that if you REALLY want (preserve the details about the array inside the function), but you will have to do X absurd thing.
Tokin
Btw is metaprogramming in C a thing? Do ppl write code within C code? Or a program that outputs a program
MᏫᎻᎯᎷᎷᎬᎠ
You don't need to overload it Just use for loop and a std::cin inside it
MᏫᎻᎯᎷᎷᎬᎠ
Oh Then you need to overload it Just do this in your class std::istream& operator >>(std::istream& is){ //Your input return is; }
Anonymous
Please tell me best tutorial about c++
Dima
google is the best
Anonymous
hey all please can someone tell me how to write a self protecting programme or software i have tried searching on google i did'nt got a better results if anyone know please answer or even if you know some that could help me it will also be helpful
Alex
what is self-protecting?
Anonymous
self protecting are those which cannot be uninstalled easily like u cannot just go and uninstall it
Anonymous
i call it self protecting b'cause when i searched on google from there i got the term
Anonymous
yes
Anonymous
You write an entire custom driver that enforces the policy
Anonymous
you know?
Anonymous
Then hope nobody boots into safe mode
Anonymous
like hardware level programming?
Anonymous
No
Anonymous
Drivers don't always have to be hardware
Anonymous
is there any other way this is the only way?
Anonymous
Use Linux Get a TPM Grow a beard (optional) Set up dm-verity on your entire system Enable secure boot and pin the key in the TPM
Anonymous
But this will make the entire system immutable
Anonymous
ok i think first option was good thanks for your reply
Anonymous
Is posix semaphore (sem_wait) is faster than traditional unix v (semop) semaphore?
Sohit
Anyone interested to know where to practice for programming on a daily basis?
Noor
How to check if terminal emulator support EscapeSequence before printing it?
Abishek khanna
How to convert minute to second in c language
Abishek khanna
Any one tell me solution
Dima
lol
Anonymous
Am really sorry that was purely unintentional, pocket touch caused this spam, This is very embarassing.😔
Anonymous
Hii everyone
Anonymous
How to convert minute to second in c language
using namespace std::chrono; const auto seconds = duration_cast<second>(minutes);
Cengizhan
C++ ofc
He asks in C. It was rhetoric.
Anunay
😂
Anunay
C++ Masterrace
Anonymous
How to convert minute to second in c language
multiply by 2. add 10. multiply by 5. add 10 again. divide by 10. subtract 6. divide by 60.
Anonymous
this is high performance method
Anonymous
x = (10, 20, 30); // x = 30 x = 10, 20, 30; // x = 10 What's the logic behind this?
Dima
lol
Anonymous
operator precedence
Alright thanks
piggyho
How to convert minute to second in c language
how would you do it with a paper and pencil
Anonymous
if(sizeof(int) > -1) printf("True"); else printf("False"); Why does the if condition evaluate to false? The size of an integer is supposed to be greater than -1.
Cengizhan
Compile your code with warning -Wsign-compare in GCC and see.
Anonymous
printf(3 + "ABCDEFG") prints DEFG The integer is defining the starting index of the string to be printed. Does this work anywhere else other than printf? Also, where can I find the documentation for this method of printing?
Cengizhan
No readability, no maintability etc.
Anonymous
@cngzhnp @tute_avalos Thanks 👌
Anonymous
Hey community. I'm new to programming and I would like you guys to revise my code. PRECISION: I DON'T NEED HELP, i just want you to check it out. I'm fan of lambda function in python, and I try to use in C in order to reduce the code-making time. Just need some suggestions, if I should focus on if...else, or use conditional operator ("?") as much as I can (Specially for small codes)
Anonymous