Anonymous
Hey
Indolent
Hey
So you must be a die hard coder
klimi
Hey
Hey!
Wojak
Can anyone share link to a telegram group of Competetive Coding using C++ ?
Wojak
Or a similar community
Wojak
Thanks @naolarega
M.Khorram
Thanks @naolarega
You might find one. However, It would not be an absolute answer But you can create the first one and invite others to that group.
Wojak
Naah, I don't want to create a group. It's gay to be an admin
Wojak
I would prefer to learn and escape and not be into handling others
Anonymous
Hey
Anonymous
Hey
Apk
Hey
hey fellow programmer!
Anonymous
Hi
V01D
Hi
/report
V01D
Come on we all know it's a thot bot
Roxifλsz 🇱🇹
Hi
/ban hi bot
Roxifλsz 🇱🇹
Thot has been patrolled
Roxifλsz 🇱🇹
👌
Cute profile pic, bro
Roxifλsz 🇱🇹
RJ
Hi
RJ
Any one c/c++ developer
RJ
Plz help me
Nameful
No, we all write Python
RJ
Oh
RJ
I want to learn Python
Anonymous
We all write Scratch actually.
Nameful
Oh
I'm joking. What's your question?
Nameful
RJ
Oh I want to learn coding
Nameful
But you don't know where to start?
Andrey
can anyone help me please, why do I get constantly 8 if I want to get size of an element in the array? and why do i get 48 as the size of an array? how I think, i should get the size of an element as max element size of the whole array, in my case, size of apricotadds, but its size isnt 8
Nameful
Look up tutorials on the Internet and write code
Nameful
Discuss code with people (very valuable)
Nameful
And read other people's code
Nameful
Those things are important
RJ
Thanks
Nameful
But yeah, I suggest you start with tutorials on the Internet
klimi
Thanks
Don't pm random people bruh, it is not ok to do so
RJ
Ok
Anonymous
Do you have to get its length in compile time?
Andrey
Do you have to get its length in compile time?
yes, i understand now, 8 is size of char*
Andrey
What you get is the size of pointer instead of the length of the string.
how i understand, it is better to use char *fruit[] than char fruit[6][8], because it takes less memory, yes? and also it is easier to use
Anonymous
What language are you using, c or c++?
Andrey
c
Anonymous
There is a solution in c++.
Andrey
solution to what?
Anonymous
Get the length in compile time
Anonymous
constexpr unsigned len(const char* str) { return *str ? 1+len(str) : 0; }
Anonymous
This function can be evaled in compile time.
Anonymous
You are welcome.
Anonymous
#include <stdio.h> #include <conio.h> int main() { int a,b,c; float Ave; Clrscr () ; printf("\n Average of 3 integer"); printf("\n Input 3 integers"); scanf("%d,%d,%d",&a,&b,&c); Ave=(a+b+c)/30; print("\n Average is %f",Ave); getchc); } Hey guys, anyone know why it didn't work?
Andrey
You are welcome.
is it possible to create get_size(const char *array) function in c? i have no idea how to do it. this function has to return the length of an array. when i try to do it, i get an error: 'sizeof (array)' will return the size of the pointer, not the array itself The function is: int get_size(const char *array) { return sizeof(array)/sizeof(array[0]) - 1; }
Anonymous
It says undefined reference to 'print' 👉print("\n Average is %f",Ave);
Anonymous
should be printf
Anonymous
It's telling you there is no definition for print, which is true
Anonymous
should be printf
Thank u, what about clrsc () ;?
Anonymous
It's also undefined
Anonymous
clrscr()
Anonymous
clrscr()
Error :Expected ';' before 'printf' Should I write? printf clrscr() ;
Anonymous
Yeap
Anonymous
Necessary to terminate every statement
Andrey
No you cannot since the array decays to a pointer, In C++ you could do this #include <cstdlib> template <class T, size_t N> size_t get_size(T(&)[N]) { return N; }
size_t get_strlen(const char *string) { size_t length = 0; while(*string != '\0') { length++; string++; } return length; } this one works 🤭
Anonymous
Just use strlen
olli
size_t get_strlen(const char *string) { size_t length = 0; while(*string != '\0') { length++; string++; } return length; } this one works 🤭
but there is no guarantee that strlen is the size of the array. Also, the result of strlen depends on your content not necessarily on the buffer length. #include <cstdlib> #include <cstdio> size_t get_strlen(const char *string) { size_t length = 0; while(*string != '\0') { length++; string++; } return length; } template <class T, size_t N> size_t get_size(T(&)[N]) { return N; } int main() { char msg[] = "Hello"; msg[0] = '\0'; const auto strlen = get_strlen(msg); const auto size = get_size(msg); printf("strlen: %x\nsize: %x\n", strlen, size); } Outputs: Program returned: 0 strlen: 0 size: 6 https://godbolt.org/z/erKn8P
SUJAY
Keyboard input not working on DosBox for Turbo C++ I used DosBox on my new laptop but , its not taking any of keyboard input..like not accepting arrow, f5,f7,f8 keys too.. The problem listed above is specially for Turbo C++ compiler..