Pavel
Anonymous
z
void func()
{
const int someVar = 20;
...
}
This the result...
extern int test;
void func1()
{
const int someVar = 0xffff;
test = someVar;
}
void func2()
{
static const int someVar = 0xffff;
test = someVar;
}
func1 stores someVar on the stack.
func2 stores someVar on .rodata section.
See also: https://godbolt.org/z/8Mn3eW
Look at that RIP relative addressing to access the static const int someVar.
z
Data on the stack is always writeable.
While .rodata is not writetable.
Local variable const int someVar is semantically read only, but at runtime it is actually on the stack.
.rodata will not be writable at runtime at all, trying to write to .rodata will result in segmentation fault.
Pavel
Pavel
I mean it should be stored somewhere, right?
Pavel
Cool!
Thank you @Mysticial, @unterumarmung, @JRandomGuy
Kelvin
/get
Pavel
How do you decide which types you pass by value and which by reference? If we're talking about trivially copyable structs for example. How small should it be to start considering passing it by value?
Alex
https://stackoverflow.com/questions/30980759/when-should-i-pass-or-return-a-struct-by-value/30981026
Anonymous
Pavel
good reading, thanks
Anonymous
@𝑺𝒐𝒃𝒌𝒂
Hi
Need a book for Qt5 gui in C++. Can anyone help?
Karim-
Somebody can help me?
Avique
I am having a problem with a basic C++. I have searched around, but i only found reasons pretty different from what my code is.
The gcc error message is:
t.cpp:15:5: error: expected unqualified-id before ‘{’ token
file t.cpp is:
#include <iostream>
#include <cstdlib>
using namespace std;
#include "t.h"
class Agent
{
public:
enum e { a,b,c,d };
int z[16];
int n;
Agent
{
int i;
for( i=0; i<16; i++)
z[i] = 0;
}
};
file t.h is:
#ifndef tH
#define tH
#endif
I would just paste a picture of both files together in a window, small image... for me, that would be better because it has syntax highlighting - but the rules...
So, what is wrong with my code? I tried to do changes with it, but this error never disappeared, except when something i know is wrong was written. What is missing or wrong in the class constructor? What is an "unqualified-id"?
Karim-
This calendar software/program should include of the following functions:
(1) Output the current date;
(2) Output the current year is a leap year or not;
(3) Output the specified date is a holiday or not, if it is, printing the holiday name;
(4) Output the date of the specified date after n (n>0 and n denotes a integer) days;
(5) Output the week No. of the current data in this year.
I don't understand 😭😭😭😭
Avique
Diego
Diego
Good luck
Anonymous
Alfredo
Avique
I am having a problem with a basic C++. I have searched around, but i only found reasons pretty different from what my code is.
The gcc error message is:
t.cpp:15:5: error: expected unqualified-id before ‘{’ token
file t.cpp is:
#include <iostream>
#include <cstdlib>
using namespace std;
#include "t.h"
class Agent
{
public:
enum e { a,b,c,d };
int z[16];
int n;
Agent
{
int i;
for( i=0; i<16; i++)
z[i] = 0;
}
};
file t.h is:
#ifndef tH
#define tH
#endif
I would just paste a picture of both files together in a window, small image... for me, that would be better because it has syntax highlighting - but the rules...
So, what is wrong with my code? I tried to do changes with it, but this error never disappeared, except when something i know is wrong was written. What is missing or wrong in the class constructor? What is an "unqualified-id"?
It was faster solving in a forum. The problem is missing "()" after the constructor name, in its definition.
Anonymous
Anonymous
fatal error: folly/Format.h: No such file or directory
#include <folly/Format.h>
^~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/langdetectpp.dir/build.make:86: recipe for target 'CMakeFiles/langdetectpp.dir/src/Detector.cpp.o' failed
ㅤㅤㅤ
int main()
{ int m[5][5]= {{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
};
cout<<m[5][5];
return 0;
}
what's my error
S__R
int main()
{ int m[5][5]= {{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
};
cout<<m[5][5];
return 0;
}
what's my error
You should use a for loop to print the elements
S__R
ㅤㅤㅤ
Igor🇺🇦
Anonymous
Hi
Anonymous
I want to c language pdf
Anonymous
Anyone send me
Diego
/get cbook
Diego
Anyone send me
The rules also say you can't ask for PDFs, you've gotta find them yourself
yue
😏
Anonymous
Ok
Programmer
KIBUTI BOT
Any pdf with solved problems ,c programing plz
Manish
Hi, want to return a unique ptr without transferring the ownership. Caller method should able to perform manipulation on object content by unique ptr. How define such method? Help appreciated
olli
Manish
It should be own by class in which I would like define it.
Alex
Santhu
Can any body explain program about implement of emi calculator
olli
It should be own by class in which I would like define it.
but why do you return it then? and how? because the following fails to compile
struct Foo {
std::unique_ptr<int> Ptr;
Foo(int Val)
: Ptr(std::make_unique<int>(Val))
{}
std::unique_ptr<int> Bar() {
return this->Ptr;
}
};
<source>:11:16: error: call to deleted constructor of 'std::unique_ptr<int>'
return this->Ptr;
Vlaspet
Hi, how are you??
Jalal
Hello, I have a .nsi file and I want to check if a font is already installed. How can I do it?
Santhu
Renuga
#include <stdio.h>
#include <conio.h>
#include <string.h>
void bubbleSort(char [],int);
void exchange(char [],int,int);
void main()
{
int x=11;
char word[12]="THISISATEST";
printf("\nDescending unSorted:%s", word);
bubbleSort(word,x);
printf("\nDescending Sorted : %s", word);
getch();
return 0;
}
void bubbleSort(char array[],int arraySize)
{
int i,j;
for(i=0;i<arraySize-1;++i)
{
for(j=i+1; j<arraySize; ++j)
{
if(array[i]<array[j])
{
exchange(array, i, j);
}
}
printf("\nIteration %d Sorted : %s",i+1,array);
}
}
void exchange(char array[],int index1,int index2)
{
char temp;
temp=array[index1];
array[index1]=array[index2];
array[index2]=temp;
}
Renuga
this bubble sort is giving this output
Descending unSorted:THISISATEST
Iteration 1 Sorted : THISISATEST
Iteration 2 Sorted : TTHIISASEST
Iteration 3 Sorted : TTTHIIASESS
Iteration 4 Sorted : TTTSHIAIESS
Iteration 5 Sorted : TTTSSHAIEIS
Iteration 6 Sorted : TTTSSSAHEII
Iteration 7 Sorted : TTTSSSIAEHI
Iteration 8 Sorted : TTTSSSIIAEH
Iteration 9 Sorted : TTTSSSIIHAE
Iteration 10 Sorted : TTTSSSIIHEA
Descending Sorted : TTTSSSIIHEA
Renuga
BUT I SHOULD GET THIS OUTPUT
Descending unSorted : THISISATEST
Sorted : TTHISISATES
Sorted : TTTHISISASE
Sorted : TTTSHISISAE
Sorted : TTTSSHISIEA
Sorted : TTTSSSHIIEA
Sorted : TTTSSSIHIEA
Sorted : TTTSSSIIHEA
Sorted : TTTSSSIIHEA
Sorted : TTTSSSIIHEA
Descending Sorted : TTTSSSIIHEA
Renuga
WHAT IS WRONG IN MY CODES?
Anonymous
#include <stdio.h>
#include <conio.h>
#include <string.h>
void bubbleSort(char [],int);
void exchange(char [],int,int);
void main()
{
int x=11;
char word[12]="THISISATEST";
printf("\nDescending unSorted:%s", word);
bubbleSort(word,x);
printf("\nDescending Sorted : %s", word);
getch();
return 0;
}
void bubbleSort(char array[],int arraySize)
{
int i,j;
for(i=0;i<arraySize-1;++i)
{
for(j=i+1; j<arraySize; ++j)
{
if(array[i]<array[j])
{
exchange(array, i, j);
}
}
printf("\nIteration %d Sorted : %s",i+1,array);
}
}
void exchange(char array[],int index1,int index2)
{
char temp;
temp=array[index1];
array[index1]=array[index2];
array[index2]=temp;
}
#include <stdio.h>
#include <string.h>
#define SWP(a, b) do { int _SWP = (a); (a) = (b); (b) = _SWP; } while(0)
#define BUBBLE(a, cmp, b) if((a) cmp (b)) { SWP(a, b); done = 0; }
int main() {
char data[128]; // prevent read-only me ory error,
int len, done; // or use "-fwritable-strings" flag
sprintf(data, "THISISATEST"); len = strlen(data);
printf("\n\nforward sorting: '%s'\n\n", data);
do {
done = 1;
for(int i = 1; i < len; i++)
BUBBLE(data[i-1], >, data[i]);
printf(" %s\n", data);
} while(!done);
// sprintf(data, "THISISATEST"); len = strlen(data);
printf("\n\nbackward sorting: '%s'\n\n", data);
do {
done = 1;
for(int i = 1; i < len; i++)
BUBBLE(data[i-1], <, data[i]);
printf(" %s\n", data);
} while(!done);
return 0;
}
Renuga
thank you
Anonymous
Notice how an a high or low value can get moved multiple times in the same sweep.
World Stream
Did any interested to learn C Programming full course for free
World Stream
DM me
Aaditya
Aaditya
World Stream
/admin
klimi
Aaditya
/admin
Will u teach me c programming
World Stream
Can I send a c programming tutorial link in your group
Anonymous
Normally people put links in profile Bio...
World Stream
World Stream
Check my bio
Anonymous
#include <stdio.h>
#include <string.h>
#define SWP(a, b) do { int _SWP = (a); (a) = (b); (b) = _SWP; } while(0)
#define BUBBLE(a, cmp, b) if((a) cmp (b)) { SWP(a, b); done = 0; }
int main() {
char data[128]; // prevent read-only me ory error,
int len, done; // or use "-fwritable-strings" flag
sprintf(data, "THISISATEST"); len = strlen(data);
printf("\n\nforward sorting: '%s'\n\n", data);
do {
done = 1;
for(int i = 1; i < len; i++)
BUBBLE(data[i-1], >, data[i]);
printf(" %s\n", data);
} while(!done);
// sprintf(data, "THISISATEST"); len = strlen(data);
printf("\n\nbackward sorting: '%s'\n\n", data);
do {
done = 1;
for(int i = 1; i < len; i++)
BUBBLE(data[i-1], <, data[i]);
printf(" %s\n", data);
} while(!done);
return 0;
}
Macros? Really?
Anonymous
Check my bio
This is getting a little off-topic... You would fit in better over at the "Cwithme" Telegram group.
Anonymous
hehe
Evil grin
Anyone here familiar with global gnu
World Stream