MRT
i dont see any relation object, but this->deleteLater() not working
Ava
How does one receive enter as user input
Diego
How does one receive enter as user input
Each key has a specific ASCII character string combination tied to it
Diego
If you can already receive individual keys as user input, then simply match the one for enter/return
Diego
You know I really dislike how I'm googling that exact question and the first 6 results somehow resolve to lmgtfy or "x minutes of googling"
AHMED
#include<iostream> using namespace std; int getAve(int a[], int n){ int sum = 0; for (int i = 0; i<10; i++){ sum += a[i]; } return sum/n; } int main() { int myArray[10]; cout<<"Enter 10 integers separated by the enter key:\n"; for (int i = 0; i<10; i++){ cin>>myArray[i]; } cout<<"The average is: "<<(double)getAve(myArray[], 10); }
AHMED
+ g++ -w -Wall -std=c++14 -O2 -o main.out main.cpp -lm main.cpp: In function ‘int main()’: main.cpp:30:54: error: expected primary-expression before ‘]’ token cout<<"The average is: "<<(double)getAve(myArray[], 10); ^ + ./main.out Enter 10 integers separated by the enter key:
AHMED
The program works , but why is this error?
Mar!o
ouch
Dhroov
#include <iostream> using namespace std; int main() { int a[] = {10, 20, 30, 40}; for (int i = 0; i < 4; i++) { cout << (a[i] == i[a]) << " "; } return 0; } Output: 1 1 1 1
Dhroov
Why is it equating to True? Can array name and array index be interchanged?
Dhroov
becouse you can not assign a array to another array
There's only 1 array in the code right? And I'm using the equal to operator
Dhroov
UB
Ohh okay, thanks!
Mar!o
Ohh okay, thanks!
no it's not
Dhroov
a[i] -> *(a+i) i[a] -> *(i+a) it's both legal So it's similar to: a[i] == a[i]
Yess I read online that x[y] is semantically equal to *(x+y) and since addition is commutative x[y] = y[x] = *(x+y)
Dhroov
Which is basically what you explained
Dhroov
Thanks a lot!
Mar!o
Thanks a lot!
no problem ^^
Anonymous
Give the array address and display the output of the given array declaration and initialization int num[4][5]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25} dispay the value 8
Anonymous
Help me please
Anonymous
I've been trying to do it for 6 hours
Nils
printf("%d", *(num + 7));
You can simply do printf("%d", num[7]); which is identical
Vlad
And why it works the way it does
gab
a[i] -> *(a+i) i[a] -> *(i+a) it's both legal So it's similar to: a[i] == a[i]
Only if a[0] and i are of the same type or size a[i] -> *(a+i*sizeof(a[0])) i[a] -> *(i+a*sizeof(i))
Vlad
What's difference between 5 + 2 vs 2 + 5
MRT
What's difference between 5 + 2 vs 2 + 5
The first is the first number 5,The second is the first number 2😎
Vlad
Well, apparently not, my bad. Not sure why, though.
It doesn't care what to take as a base address and what as an offset
Anonymous
Hi I have a program that I open every time, in Chrome it opens two tabs from their site that I downloaded How to edit the program?
Anonymous
Vlad
I bet it's some kind of adware
Anonymous
What is tools?
https://en.m.wiktionary.org/wiki/tool You are welcome
Vlad
It usually just messes up with your files/configs but you can clean that up
Vlad
#ot
Mamas
Please i have a question to ask ..can I.. please
Anonymous
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main(){ pid_t pid; int x = 5; pid = fork(); printf("pid fork() returned value = %d\n", pid); x++; if (pid < 0){ printf("Process creation error"); exit(-1); } else if (pid == 0){ printf("Child process:"); printf("\nProcess id is %d", getpid()); printf("\nValue of x is %d", x); printf("\nProcess id of parent is %d\n", getppid()); } else{ printf("\nParent process:"); printf("\nProcess id is %d", getpid()); printf("\nValue of x is %d", x); printf("\nProcess id of shell is %d\n", getppid()); } return 0; } OUTPUT: pid fork() returned value = 1282 pid fork() returned value = 0 Child process: Parent process: Process id is 1282 Process id is 1281 Value of x is 6 Value of x is 6 Process id of parent is 1281 Process id of shell is 10 Why the output is printing like this?
Anonymous
when the fork() returned is 1282 which is process id(parent), then it should print everything inside the else{} and then when fork() return is 0 it should print everything inside else if (pid == 0){} when fork() is done, does the two process run in parallel?
Mamas
I need help.please
Anonymous
Mamas
just ask
Okay can it be possible to study programming without a computer ..or Android phone..
Mamas
Can that work??
Mamas
Okay thanks for your help...
Anonymous
Hi guys i have a question, why i can do class p{ int *r; int& operator[](unsigned int index) const { return *r; } } And not class p{ int r; int& operator[](unsigned int index) const { return r; } } Thanks guys
Andrew
Okay thanks for your help...
i mean read a book about programming, if you really want to learn
H
I need help.please
dontasktoask.com
Anonymous
Mamas
i mean read a book about programming, if you really want to learn
So please which book can I use for c programming .. for a beginner like me...
Andrew
/get cbook
Anonymous
Mh without const works
I mean i understand why it works without const, but with why it wouldn't work? I don't change class variables
MRT
in windows after start many threads in application i get this error QMutex: destroying locked mutex;QThread: Destroy while thread is still running, why ?
MRT
staticMetaObject <not accessible>
MRT
I just put a few small items on the stack
Anonymous
Are boost::python questions appropriate here?
Anonymous
Can you guys give me a sample code of 3D Arrays?
あおい ハート
How can i Create multiple objects in a for loop? Is it advance thing to do which i should leave for now?
Diego
The thing you should be worrying about is, instead, how will you access these objects
あおい ハート
The thing you should be worrying about is, instead, how will you access these objects
Ohh never thought about that, but can i create them in global scope?
Diego
I mean sure, you create them somewhere in memory and receive a pointer back to them