Hussein
In math.h you will only get definition of the functions you are using not the whole source code
Hussein
thanks alot
This group chat doesn't allow me to send a link here You can easily find it by simply googling "glibc source code"
Anonymous
Use std::any
Hussein
There are tons of libc, you should check the libc source code that you used
yeah exactly on most of Linux distros like ubuntu , debian , fedora or arch you should probably check glibc but on few other distros like alpine linux and void linux you should check the source code of MUSL c standard library on Windows you are more likely out of luck if I’m not mistaken
%Nikita
Hello. Who can explain why I assign one value to variable, but in this variable I got another value, after assigning? This what I got in GDB: 66 size_t l_idx = strchr(seq, tolower(letter)) - seq; (gdb) n 67 (gdb) p l_idx $1 = 17 (gdb) p strchr(seq, tolower(letter)) - seq $2 = 469123456210287 (gdb) wtf
Ольга
Hi to all. I tried to do as I was advised but still nothing works, refuses to accept input at all (35 lines of code). If I just use scanf, it only remembers what goes before the interrupt, and I need to enter a two-word book title. Maybe someone knows what I'm doing wrong? I will be grateful for the advice. https://onlinegdb.com/XMoGNEShIk
\Device\NUL
I've told you several times, If you input something with scanf using enter, there will be remained newline on input stream
Ольга
use int main not void main
But I use int main
\Device\NUL
You also has no NULL handling if malloc fails, and using printf rather than putchar() to output single char
\Device\NUL
But I use int main
Okay sorry, i miss read it
Ольга
You also has no NULL handling if malloc fails, and using printf rather than putchar() to output single char
I'm sorry, but I don't really understand why the symbol, if I need the word itself?
Ольга
I'm sorry, but I don't really understand why the symbol, if I need the word itself?
And where should I use it? In all outputs or only in the Output function?
Ольга
I've told you several times, If you input something with scanf using enter, there will be remained newline on input stream
I make something like scanf ("[^\n] %c", ptr[i]. name, & instr); It would be better or You not mean that?
\Device\NUL
and I suggest to limit the buffer using max field width specifier like "%100[^\n], otherwise its same like gets()
Ольга
I haven't try it, but my practice is scanf(); getchar()
I did so, but now the problem is that the cycle has become endless
Ольга
Ольга
Oh sorry I miss one think, now cycle is Okey
Although everything is fine with the cycle now, but even so it does not want to enter the title of the book
Ольга
Although everything is fine with the cycle now, but even so it does not want to enter the title of the book
I use scanf(%[^\n] %s, ptr[i]. name, & instr) ; getchar () It is like I nead or I'm wrong again?
\Device\NUL
first line will input into ptr[i].name because the specifier will read the input until found newline
Anonymous
how do i create a linked list data with struct?
Anonymous
how do i create a linked list data with struct?
i want to input some integeres like array
Ольга
first line will input into ptr[i].name because the specifier will read the input until found newline
I realy don't know how to do it, I do sme just in scanf use instr, & c. Like in int main char instr[20], char c. And then Strcpy(ptr[i]. name, instr) ; . Becouse when I try without cycle it's working
F
EXAMPLE 1 repeat.txt 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 output 1 0 1 0 0 1 0 1   EXAMPLE 2 repeat.txt 16 1 2 49 189 16 1 2 49 5 2 16 1 2 49 189 16 1 2 49 5 2 16 1 2 49 189 16 1 2 49 5 2 16 1 2 49 189 16 1 2 49 5 2 16 1 2 49 189 16 1 2 49 5 2 16 1 2 49 189 16 1 2 49 5 2 output 16 1 2 49 189 16 1 2 49 5 2  
Anonymous
Hello. Who can explain why I assign one value to variable, but in this variable I got another value, after assigning? This what I got in GDB: 66 size_t l_idx = strchr(seq, tolower(letter)) - seq; (gdb) n 67 (gdb) p l_idx $1 = 17 (gdb) p strchr(seq, tolower(letter)) - seq $2 = 469123456210287 (gdb) wtf
Suppose say that the letter is not found and strchr returns a null pointer. Then subtracting seq from it results in Undefined Behavior. The difference in the outputs could be because you are converting a ptrdiff_t to size_t in the former case and printing the ptrdiff_t in the latter case. In any case, doing such things may result in Undefined Behavior. The right way to do this would be to check if the return value from strchr is not a null pointer and only then subtract seq from it
Anonymous
Read the pinned message. In that there is a Resources section pointing to books and videos using which you can learn C++
𝓮𝓷𝓮𝓷𝓳𝓪
Send me the previous link
%Nikita
Suppose say that the letter is not found and strchr returns a null pointer. Then subtracting seq from it results in Undefined Behavior. The difference in the outputs could be because you are converting a ptrdiff_t to size_t in the former case and printing the ptrdiff_t in the latter case. In any case, doing such things may result in Undefined Behavior. The right way to do this would be to check if the return value from strchr is not a null pointer and only then subtract seq from it
Thx anyway, really weird > the right way to do this would be to check if the return value from strchr is not a null pointer Sure, no way. There is an “if” statement above, and strchr in this case physically can’t return NULL. Here it is: … if (!((letter >= ‘A’ && letter <= ‘Z’) || (letter >= ‘a’ && letter <= ‘z’))){ fprintf(stderr, “error: \’%c\’: not a letter. Abort.\n", letter); exit(EXIT_FAILURE); } const char *seq = “qwertyuiopasdfghjklzxcvbnm”; size_t l_idx = strchr(seq, tolower(letter)) - seq; … Buut just in case I also have tried same, but now “letter” is definitely in string, ‘a’ for example. And I tried it without “tolower()” function. Same results.
%Nikita
Maybe ‘gdb’ works with pointers different somehow?
Hussein
but this might not be the reason you are getting the bug
%Nikita
To this exact struct in this struct
Anonymous
To this exact struct in this struct
i want do with this struct: struct node { int data; struct node *next; }
Anonymous
but i don't know how i don't know its syntax
Anonymous
it's objective programming i guess
Anonymous
Why are you subtracting "seq" from the letter
He is subtracting seq from the return value of strchr to get the index of the character in the string.
%Nikita
Why are you subtracting "seq" from the letter
You know, it is weird the way to get letter index of string. strchr(s,c) returns pointer to a ‘c’ character in ‘s’ string if it was found there otherwise it returns NULL. And when I get pointer to letter ‘c’ which is in string ‘s’, to get index of this letter I should subtract ‘s’, because string name itself is a pointer ti the first letter in this string
Hussein
i want do with this struct: struct node { int data; struct node *next; }
Create an array of that then loop on each element to print the integer
%Nikita
i want do with this struct: struct node { int data; struct node *next; }
1. Allocate first struct 2. Allocate other structs within this struct by: node = node->next; node->next = malloc(sizeof(struct node)); 3. Fill it by using the same way of iterating list as in ‘2’ 4. And then print values in list using the same way of iterating as in ‘2’
Hussein
Make sure you sure you passed the right type to tolower() And also check if you have got any compiler warnings those often warn you if you handled types incorrectly
%Nikita
Make sure you sure you passed the right type to tolower() And also check if you have got any compiler warnings those often warn you if you handled types incorrectly
Yeah, have checked. No warnings no errors. Types are correct. On windows it works fine. But on gentoo something went wrong
Hussein
On debian works just fine This is weird
Prakhar
Can anyone help me explaining the output of this C program. The output is like this: 7 7 12 49 https://pastebin.com/w2VcHXp1
● Igor
Can anyone help me explaining the output of this C program. The output is like this: 7 7 12 49 https://pastebin.com/w2VcHXp1
#define PRODUCT(x)(x*x) PRODUCT(i+1) is replaced by i + 1 * i + 1, and i = 3 so thats 3 + 3 + 1 = 7 note that x*x should be (x)*(x) if you want the right result (16) PRODUCT (i++) = i++*i++, which is 3*4, since the ++ operator is computed after the *, and now i was incrimentented twice (i = 5) PRODUCT(++i) = ++i*++i = 7*7, since the increment is executed before the multiplication
Anonymous
i want to input some integers untill the given number is -1 and save them a a linked list! how can do it?
● Igor
Anonymous
i want to input some integers untill the given number is -1 and save them a a linked list! how can do it?
I assume you to know how to create and append elements into linkedlist. Let's say your input is n; then... while(n != -1) { // add into linked_list }
Anonymous
● Igor
how can i push it to the linked list?
you gotta google that since you may be using your own implementation of a linked list or maybe some lib for that...
● Igor
it's not trivial to explain it
Anonymous
you gotta google that since you may be using your own implementation of a linked list or maybe some lib for that...
i searched a lot! but i haven't found the solution. i don't want use class or insert... there is an easier solution
● Igor
i think you need to use at least a struct
Anonymous
i think you need to use at least a struct
yes of course struct node { int data; struct node *next; } but this question must be easier than things i found in google because the purpose of the question is to become more familiar with Pointer and struct, not the concepts of objective programming
Anonymous
@Zaur1604 Read the rules and use the pastebin links provided to post your code. Delete your message and post it again using pastebin links.
Anonymous
Oh thank you so much You are right. I forgot that if you want to use that kind of statement then you have to put them inside braces.
Your code is wrong irrespective of whether you put the parentheses around x or not. Your code exhibits Undefined Behavior. Read the link in the message above this or refer to the Resources section of this channel.
Prakhar
Your code is wrong irrespective of whether you put the parentheses around x or not. Your code exhibits Undefined Behavior. Read the link in the message above this or refer to the Resources section of this channel.
I read it. From the looks of it, I believe that it is happening because I am trying to modify the variable i more than once between two sequence points. By the way, will I be able to circumvent this problem by performing the incrementation in separate lines twice before the computation?
Anonymous
I read it. From the looks of it, I believe that it is happening because I am trying to modify the variable i more than once between two sequence points. By the way, will I be able to circumvent this problem by performing the incrementation in separate lines twice before the computation?
Sequence points were before C++11. C++11 changed the evaluation order rules. Anyway you have the right idea. The answer to your question is yes. Incrementation done in separate statements will not have this issue.
Prakhar
Okay thanks for your help