Ehsan
No
okay you need to read about stacks and how to make stack based calculator
Ehsan
Thank you very much ❤️;
you can also use binary trees to implement it
𝐄𝐲𝐚𝐝
Anonymous
I have read the rules and I agree with them
Ishikawa
How to use variables in header files
Ishikawa
And access them from main function
Ishikawa
Using global variables gives segmentation fault
olli
Using global variables gives segmentation fault
if you declare variables in your header, they're still global. I doubt your segfault is related to using global variables. To answer your question foo.h extern int x; foo.c #include "foo.h" int x; int main() { x = 0; return x; }
Ishikawa
I understand that they are global but using them simply generates segmentation fault
olli
did similar, segmentation fault still there
hard to reason without seeing code, can you share it?
Ishikawa
OK
Ishikawa
Its very file though, should I still share
Ishikawa
Ishikawa
Its very file though, should I still share
*Its very BIG file though, should I still share
Diego
https://gist.github.com/
olli
in the cpp file I mean
you need to define the global variable. Usually you define it in one source file and declare it in the header to make it 'visible' to other source files.
Ishikawa
Not sure what's causing this fault then.😭
olli
Not sure what's causing this fault then.😭
impossible to say without seeing the code.
Diego
*Its very BIG file though, should I still share
Please use a gist, it's the link I shared
Ishikawa
Is there any tool to debug these fault?
Nameful
Ask in the offtopic group
Anonymous
Useless group
Anonymous
"how to free download ram"
Ishikawa
Useless group
I see that you're one warn away from 'banned'.
Hariyana Grande
whats (void*) mean?
Nameful
whats (void*) mean?
Typecast to void*
Hariyana Grande
it says - "the cast to void* is to prevent a possible warning from the compiler"
Hariyana Grande
Typecast to void*
you mean typecasting like (int) or(float)?
Nameful
void* is a pointer
Hariyana Grande
what kind of error would you get if you didn't use (void*) ?
Hariyana Grande
ok got it thanks
Anonymous
Hi guys
Ehsan
Chill dude
Anonymous
Has anybody c questions i csn help for 1 hour
Sandeep
String& operator=(String&& other) noexcept { printf("Moved! \n"); m_Size = other.m_Size; m_Data = other.m_Data;//😐how is this line causing a memory leak😐 other.m_Size = 0; other.m_Data = nullptr; } Assume current object already has something in m_Data
Anonymous
Since object already had data
Hariyana Grande
#include<stdio.h> int main() { int a=10; printf("%d\n", a); return 0; } int f() { printf("Hi"); return 0; }
Hariyana Grande
whats wrong with this code why it doesnt printing "hi"
Hariyana Grande
do we really have to ? im trying this way im noob pls tell me
Anonymous
How to leave this group??
Hariyana Grande
there is an option if you click three vertical dots
Anonymous
How to leave this group??
click the 3 dots, there's an option to leave group.
Anonymous
#cppbookguide
Hariyana Grande
thanks
Hariyana Grande
int addmult(int i, int j) { int k, l; k = i + j; l = i * j; return (k, l); } int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d %d\n", k, l); return 0; }
Hariyana Grande
why this program giving output = 12 12 isnt it should be 7 12 ?
Anonymous
(k, l) will always return l
Hariyana Grande
srry i didnt get your point
Anonymous
srry i didnt get your point
return (k, l); will return l
Hariyana Grande
could u elaborate
Anonymous
int addmult(int i, int j) { int l; l = i * j; return l; } int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d %d\n", k, l); return 0; }
Hariyana Grande
wait let read it
Hariyana Grande
gotcha thanks
Hariyana Grande
The Comma Operator (,): The comma operator, written as a comma (,) takes two operands. It evaluates its left operand and discards the value. It then evaluates its right operand, and returns that value as the result of the expression. 7 + 3, 6 * 2 // Gives 12 3,14 // Gives 14 (and not pi)
Hariyana Grande
jst in case if anybody wanted to know i pasted the explaination here.
Pankaj
Pankaj
Some one explain this program
ɴꙩᴍᴀᴅ
Implicit conversion from int to char changes the value from 255 to -1 so it will print 9
olli
The code is bad, the signedness of char is implementation defined and the arithmetic operating might be UB.
Talula
Some one explain this program
char c = 255 means it is already 0xFF adding 1 to it would make it 0x00 adding 10 to it would make it 0x09...
сумбула
hi guys i have a problem: a and b is given using bitwise "and" operator calculate x so that a&x = b&x (find the smallest x ) i wrote my code like this #include <iostream> using namespace std; int main() { int x = 1; size_t a, b; cin >> a >> b; while (true) { if ((a & x) == (b & x)) { cout << x; break; } ++x; } return 0; } but there is a time limit in my code. Please, can anyone suggest me any faster algorithm to handle this.
Anonymous
https://www.quora.com/In-the-C-language-what-should-be-the-answer-of-char-c-125-c-c-10-printf-d-c look this , might be helpful.
GHAMDAN_NSHWAN
size_t solve(size_t a, size_t b) { size_t x = ~(a ^ b); return x & ~(x - 1); }
How can writing same this the message.....🤔🤔🤔🤔
Anonymous
Based