if i have the following code:
pid_t pid=fork();
pid_t pid2=fork();
pid_t pid3=fork();
Can i handle every single process just by doing
if(pid==0)//son else if(pid2==0)//son else if(pid3==0)//son else //parent
I need to learn pointers in c++..
So i need a basic code with pointers to understand
Anonymous
okayy
ex4_mp1e
👍👍
Anonymous
#include <iostream>
using namespace std;
int main () {
int var = 20; // actual variable declaration.
int *ip; // pointer variable
ip = &var; // store address of var in pointer variable
cout << "Value of var variable: ";
cout << var << endl;
// print the address stored in ip pointer variable
cout << "Address stored in ip variable: ";
cout << ip << endl;
// access the value at the address available in pointer
cout << "Value of *ip variable: ";
cout << *ip << endl;
return 0;
}
Anonymous
ex4_mp1e
Thanks
Anonymous
you can inbox privaye for me
Anonymous
If you need
ex4_mp1e
Ok
Anonymous
//Two_Sum_Algorithm
int main(){
vector<int>ve;
vector<int>opve;
int rang,inp;
cout<<"enter the size of Array"<<endl;
cin>>rang;
for(int i=0;i<rang;i++){
cin>>inp;
ve.push_back(inp);
}
int target;
cout<<"enter the target "<<endl;
cin>>target;
//for (int i = 0; i <= ve.size()-1; i++)
//cout << ve[i] << " ";
for(int i=0;i<ve.size();i++){
int temp=0;
temp=target-ve[i];
int tempinornot=0;
for(int i = 0;i<opve.size()-1;i++){
if(opve[i]==temp){
tempinornot+=1;
}
}
if(tempinornot==0){
opve[i]=temp;
}else{
cout<<opve[i]<<" "<<i;
}
}
// for (int i = 0; i <= ve.size()-1; i++)
//cout << ve[i] << " ";
return 0;
}