Pavel
When should I typedef structs in C?
Mar!o
It is a common practice to typedef structs in C to avoid writing struct, enum, union all over the place...
Pavel
For example, in ffmpeg (libavutil, some structs are typedef'd, while some aren't)
Pavel
Mar!o
Yeah I also don`t like to do it for that
Mar!o
Mar!o
At least how it is there. Come on just add a second variable with the correct type to make it less confusing for beginners.
Mar!o
Now it looks like the second one would be static or global
Mar!o
Also I the difference is not only at initialization, it is every time you mention the type. Without a typedef:
struct some var;
with typedef:
some var;
Mar!o
But it really populates the global namespace if you typedef anonymous types that's why many do:
typedef my_struct {
...
} my_struct;
Anonymous
Hi, I'm new of language C, have one tutorial free good for begginers?
Anonymous
Anonymous
/get cbook
Anonymous
Anonymous
How can you in c++ name a text file name after a string?
Anonymous
Anonymous
Wat
String.txt but it doesnt work with string + ".txt"
Anonymous
Anonymous
Anonymous
Anonymous
Pavel
That works
Anonymous
what does double do in c ,I googled it but dint understand.
Alex
this is floating double precision type
Anonymous
Anonymous
my frnd said it takes int and float
Anonymous
is that wrong
Alex
what do you mean "it takes"?
Anonymous
Pavel
"* Only English language is allowed, if you speak shitty English or don't understand anything in English YOU WILL BE BANNED."
Anonymous
sorry sir I got it ,thank you
Anonymous
Pavel
Thanks
BTW, what did you try?
Anonymous
BTW, what did you try?
I did something like this but didnt work. Also tried with .c_str() but after your answer I think I know the problem
Pavel
Ah, yes, I see. C-style string is a sequence of chars that ends with '\0'.
Pavel
You will get weird result if you add char* to char*
Anonymous
include <stdio.h>
double a(double x,double y)
{
double sum;
sum=x+y;
return sum/2;
}
main()
{
double j,h;
scanf("%g%g",&j,&h);
printf("%g",a(j,h));
}
Anonymous
Artöm
Anonymous
'j' and 'h' values which I entered not copied to x and y to get returned
Anonymous
Anonymous
hm, again iam trying,sorry
I want to enter j and h which should be copied to x and y to get average of j and h
Anonymous
Anonymous
Iam getting error
Anonymous
How did you understand that the values are not copied?
Anonymous
Anonymous
Iam asking whether the program is wrong
Anonymous
Screenshot (12-Aug-2020 2:16:19 PM)
Artöm
Anonymous
Anonymous
/warn
Anonymous
what is Pming
Anonymous
sorry I got it
I never do again
Balaji
👋
V01D
su
su
hi all, who interested in vscode .devcontainer development with cmake and bezel, welcome on my twitch channel, i need help on bezel config, nick the same
V01D
Seems like typedef can assign a new name to a data type.
typedef unsigned char byte
Flash
yeah even a function type
Vlad
V01D
I just learned typedef wrong, thats all.
Vlad
Vlad
I swear it gets people every time)))
Flash
V01D
I thought typedef shortens the initialization of structs and unions.
labyrinth
is there any particular reason that the unordered_map simply use collision chaining to deal with hash collision, without strategies of like transforming the linked list to RB tree or copy the data to a new space ruled under a new hash function / memory ?
Kenny
look into c++ reference
Anonymous
yep)
In which office? Moscow? USA? Israel?
Noble Friend
Hi here, need some help please.
Here is a segment of code, i want it to run while waiting for user to press a key but it loops just once and stops. Any idea on what i should do? please (I want it to keep printing '1' till the key is entered.
#include <ncurses.h>
int main (void){
char press;
while(press != 'q'){
printf("1");
press = getch();
}
printf("You pressed 'q'");
}
Thank you
Dima
you need to update 'press', because it’s not updating as I see