Anonymous
Bumpy
int & foo (const int & a , const int & b) { return (a/b); }
Bumpy
anyone knows why i get : initial value of reference to non-const must be an lvalueC/C++(461)
Jitendra
int & foo (const int & a , const int & b) { return (a/b); }
You are returning to reference but there is no pointer to return... I think if you first assign a pointer like int c = (a/b) ; Return c; should work
Anonymous
Hey everyone. Can anyone of you send me your DSA (Data Structures and Algorithms) in C++ final project. It will be a great help.
Nameful
I've never been using getch() on linux and it looks like one big problem...
Here's how I solved getch on Linux: https://github.com/Newbytee/text-roguelike/blob/experimental/ASCII%20Roguelike/Utils.cpp
Nameful
I'm not saying it's a good solution but it works
Pavel
Is it possible to create alias for variadic template parameter pack inside a class? Or somehow else allow it be accessed outside of the class For example to do something like this template<typename... Ts> struct Filter { using Components = Ts...; ... }; template <typename Filter> void test() { using Components = Filter::Components...; ... }
olli
Is it possible to create alias for variadic template parameter pack inside a class? Or somehow else allow it be accessed outside of the class For example to do something like this template<typename... Ts> struct Filter { using Components = Ts...; ... }; template <typename Filter> void test() { using Components = Filter::Components...; ... }
You could use a tuple to allow access the types template<typename... Ts> struct Filter { using Components = std::tuple<Ts...>; }; template <typename Filter> void test() { using Components = typename Filter::Components; }
Neel
template<typename... T> struct store{ template <template <typename...> class X> using convert = X<T...> };
Neel
using a = store<int, double, char> using b = typename a::template convert<std::tuple>
David
hello, friends, The two's complement is calculated by inverting the bits and adding one. e.g., three bits signed integer, -1's two complement: 001( invert)->110(plus one)->111 But how to get -128's two complement?(using 8 bits)
David
😭
David
if we have some code like this: char ch= -128; I know in memory, ch is 1000 0000, but how computer get this number?
@𝑺𝒐𝒃𝒌𝒂
if we have some code like this: char ch= -128; I know in memory, ch is 1000 0000, but how computer get this number?
Having an overview of a machine language and the evolution of the programming language, how compiler works and ASCII, you will have your answer.
Anonymous
I think two's complement of -128 is 10000001
Actually for negative no. Compiler do 2 times 2's complement ....
Garima
Actually for negative no. Compiler do 2 times 2's complement ....
According to my knowledge negative number are stored in the form of 2's complement only
Anonymous
when you do the 2's complement and if the 15th bit is 1 then you'll have to do again 2's complement...
Anonymous
I think two's complement of -128 is 10000001
Ok intelligent girl... So tell me what is your results after 2's and before 2's complement.... What is the no. that your bit represent here ?
Garima
Ok intelligent girl... So tell me what is your results after 2's and before 2's complement.... What is the no. that your bit represent here ?
Listen I am converting -2 firstly to one's complement and then adding 1 to this to get 2's complement
Garima
Ok... But have you got the right answer ?
According to me this is answer.
Anonymous
Ok then...
Anonymous
Hola
Henry
Does anyone have functions and pointers notes of C language??
Henry
Like pdfs *
Arslonbek ␈
hello there
Arslonbek ␈
i need a help
olli
Does anyone have functions and pointers notes of C language??
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
Sengar
This message couldn't be displayed on your device due to copyright infringement.
Sengar
Also coding blocks
Anonymous
Hi, Can anyone help me with c++ quiz?
Anvar
Sure
Hariyana Grande
#include <stdio.h> int main() { int i=10; printf("%d %d %d %d %d %d %d", ++i,i,i++,i,i++,i,++i); return 0; }
Hariyana Grande
output - 14 14 12 14 11 14 14
Hariyana Grande
can someone explain the flow of program
Merve
hi all, ı want to delete a element of any array? ı use keil. Could you help me please?
Anonymous
can someone explain the flow of program
this program exhibits undefined behaviour. as such, its output can depend on the phase of moon reference - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11751#c63
Hariyana Grande
then why they asked this kind of problems in mcq type exams?
Hariyana Grande
none of the option mention "undefined behavior"
Hariyana Grande
what should i do in exam if they asks this kind of questions?
Anonymous
Yes... You're right... They asked..... But it will give right answer if you write i upto 3 -4 times instead of 7 times........
Anonymous
what should i do in exam if they asks this kind of questions?
also if its a viva-voice then you might get to explain sequence point (C) or sequenced before/after (C++) rules and explain what exactly makes it undefined behaviour. but professors are egomaniacs and probably will deduct your marks for knowing more than them.
Anonymous
Yes... You're right... They asked..... But it will give right answer if you write i upto 3 -4 times instead of 7 times........
there is no right answer for undefined behaviour just like there is no right answer for 1 / 0 in the context of the field of the real numbers
Hariyana Grande
will do thanks appreciate your help
Anonymous
will do thanks appreciate your help
no that was a joke. that will definitely hurt your marks. just read about the two topics on cppreference.com and learn it for your own sake.
Anonymous
there is no right answer for undefined behaviour just like there is no right answer for 1 / 0 in the context of the field of the real numbers
As I learned , In print function evaluation is done from right to left and printing of value done from left to right... And it's true
Hariyana Grande
no i mean i will attend alternative rather than spending too much time on this
Anonymous
As I learned , In print function evaluation is done from right to left and printing of value done from left to right... And it's true
function arguments are assigned to their corresponding function parameters in an unspecified order
Anonymous
I believe that you're not well educated then writer of that book... Respect others knowledge.... If someone is telling something with confidence then he can proof it too...
Anonymous
k
Anonymous
I saw that bug on that cpp site... But there is possibility of prediction....
Anonymous
Please don't mind chandreep... 👍
Anonymous
Please don't mind chandreep... 👍
lol its nothing personal, don't worry. i might come off as angry or irritated when defending my points in a debate, but i never am.
Anonymous
I saw that bug on that cpp site... But there is possibility of prediction....
nah. you should google around about what undefined behaviour is and why undefined behaviour is undefined
Anonymous
and the two topics i mentioned on cppreference.com as well
Anonymous
Here we can't post the pic.... Otherwise I'll show you...
Anonymous
In this call it doesn’t matter whether the arguments are passed from left to right or from right to left. However, in some function call the order of passing arguments becomes an important consideration. For example: int a = 1 ; printf ( "%d %d %d", a, ++a, a++ ) ; It appears that this printf( ) would output 1 2 3. This however is not the case. Surprisingly, it outputs 3 3 1. This is because C’s calling convention is from right to left. That is, firstly 1 is passed through the expression a++ and then a is incremented to 2. Then result of ++a is passed. That is, a is incremented to 3 and then passed. Finally, latest value of a, i.e. 3, is passed. Thus in right to left order 1, 3, 3 get passed. Once printf( ) collects them it prints them in the order in which we have asked it to get them printed (and not the order in which they were passed). Thus 3 3 1 gets printed......
Anonymous
This is the text which are written in that book...
Anonymous
In this call it doesn’t matter whether the arguments are passed from left to right or from right to left. However, in some function call the order of passing arguments becomes an important consideration. For example: int a = 1 ; printf ( "%d %d %d", a, ++a, a++ ) ; It appears that this printf( ) would output 1 2 3. This however is not the case. Surprisingly, it outputs 3 3 1. This is because C’s calling convention is from right to left. That is, firstly 1 is passed through the expression a++ and then a is incremented to 2. Then result of ++a is passed. That is, a is incremented to 3 and then passed. Finally, latest value of a, i.e. 3, is passed. Thus in right to left order 1, 3, 3 get passed. Once printf( ) collects them it prints them in the order in which we have asked it to get them printed (and not the order in which they were passed). Thus 3 3 1 gets printed......
> It appears that this printf( ) would output 1 2 3. this is a wrong presumption, > This is because C’s calling convention is from right to left. this is a wrong statement, and so the conclusion is obviously wrong. Annexure J of the C17 standard - J.1.1 The following are unspecified: —The order in which the function designator, arguments, and subexpressions within the arguments are evaluated in a function call Annexure C of the C17 standard - 1. The following are the sequence points described in 5.1.2.3: — Between the evaluations of the function designator and actual arguments in a function call and the actual call.
Anonymous
also, people like Kanetkar and Balaguruswamy etc are typically listed in "books on C to avoid" or "whats the worst book you have ever read"
ŠÇÔŔPÎÕÑ
#include<stdio.h> #include<stdint.h> #define CRC16 0x8005 uint16_t gen_crc16(const uint8_t *data, uint16_t size) { uint16_t out = 0; int bits_read = 0, bit_flag; printf("\nCRC %s\n", data); if(data == NULL) return 0; while(size > 0) { bit_flag = out >> 15; out <<= 1; out |= (*data >> bits_read) & 1; bits_read++; if(bits_read > 7) { bits_read = 0; data++; size--; } if(bit_flag) out ^= CRC16; } int i; for (i = 0; i < 16; ++i) { bit_flag = out >> 15; out <<= 1; if(bit_flag) out ^= CRC16; } uint16_t crc = 0; i = 0x8000; int j = 0x0001; for (; i != 0; i >>=1, j <<= 1) { if (i & out) crc |= j; } return crc; } int main() { char buf[]="89654221256565656"; int c , r; printf ("crc check %s", buf); r = gen_crc16(buf,sizeof(buf)-1); printf("%04hx\n", r); return (0); }
Yasas
/warns
Yasas
/get cbook
Anonymous
/warns
Anonymous
/warns