Serenity
Ohhh I am so ridiculous
Serenity
I wrote a function that prints the matrices onto the screen and called it "print" and instead of using it I accidentally called printf
klimi
@Neko_cpp
Athlantian
I have a problem with my assingments in C language are there anybody can help me to do it?
Anonymous
Athlantian
It is about file handling assignment
Athlantian
But I'm a beginner for it
Asdew
Just ask the problem you're facing!
Hermann
I have a method that takes a struct array as input, but I only need the first record of this struct array. how can I take the first record? I tried &mystruct [1] but it doesn't work...
YK Y
int main(){
char *infix="a+b*c";
char *post;
intopos(infix,post);
for(int i=0;post[i]!='\0';i++){
cout<<post[i];
}
YK Y
this for loop isn't working
YK Y
can anyone explain me why it isn't?
YK Y
i'm getting the result in post(pointer of char)
Mar!o
Just do:
Mar!o
for(; *post; ++post)
YK Y
when i print cout<<post.. it works
Mar!o
Also the error is probably in the intopos function
YK Y
YK Y
YK Y
why for loop isn't
Mar!o
YK Y
sure
YK Y
can i send ss in the group?
Mar!o
Yes
Mar!o
#include<bits/stdc++.h>
using namespace std;
int isoperand(char ch){
if(ch>='a' && ch<='z'){
return 1;
}
else{
return 0;
}
}
int prcd(char ch){
switch(ch){
case'+':case '-':return 5;
case'*' : case '/' :return 10;
default : return 1;
}
}
void intopos(char*infix,char *post){
int i=0,j=0;
stack<char>stk;
stk.push('#');
while(infix[i]!='\0'){
char ch=infix[i];
if(isoperand(ch)){
post[j++]=infix[i++];
}
else{
if(prcd(infix[i])>prcd(stk.top())){
stk.push(infix[i++]);
}
else{
post[j++]=stk.top();
stk.pop();
}
}
}
while(!stk.empty()){
post[j++]=stk.top();
stk.pop();
}
}
int main(){
char *infix="a+b*c";
char *post;
intopos(infix,post);
cout<<post;
}
Mar!o
Why are you using char arrays?
Mar!o
In C++ use string :)
YK Y
when i use loop to print ..post(pointer of char array) it isn't workin
YK Y
when i print cout<<post[0]<<post[1];
YK Y
even this isn't working
Mar!o
Wait Ill look at iz
YK Y
but i print only post[0];
YK Y
this works
Mar!o
But stack is a horrible way to do that you allocate on HEAP!
YK Y
Mar!o
😂
YK Y
where i'm wrong?
Mar!o
while(!stk.empty()){
post[j++]=stk.top();
stk.pop();
}
Mar!o
you need to reset j to 0
Mar!o
As you might write outside the array bounds - SIGGEV incomming
Mar!o
Mar!o
At least that's how it looks like - maybe there is a other error. It's hard to see on a smartphone
Mar!o
while(!stk.empty()){
post[j++]=stk.top();
stk.pop();
} I guess with should copy the contents for stack to arr?
Mar!o
YK Y
Operators in the postfix array
Mar!o
Wait let me copy it into a proper text editor...
YK Y
Ok
Mar!o
And let me clean it up a little it's almost as ugly as my code!
Mar!o
Sry have a spontaneous meeting now - I will come back to this later :)
Hermann
Dhiren!!
Sure. Thanks!
Mar!o
Brian
Hey
Afoo_trader
01000001011011010100000101101110
Have you tried solving this?
Botir
Homework?
Botir
First try solve it
Dima
do you even read the rules
Dima
Anonymous
YK Y
Bohdan
Hi guys,my teacher said that I need to implement a parallel queue but in order to transfer the number of threads that will work with this function to the function as the second parameter. As I understand it, I need to make a vector of threads in private? Or something else? Can tell please?
Bohdan
Okey. My task: realize parallel queue and single queue. And compare it.
But when I realizing parallel I must add to function second parameter - number of Threads. For example:
push(const T& data, unsigned int numberOfThreads)
I don’t know how realize it and how it will be work.
@Chhotu
Plz send me some pdf
@Chhotu
C Or java
Bohdan
I don’t know why he said to do the second parameter and for what.
Yes,I have a mutex and a cv.
Maybe it is necessary that in main not to write initialization of threads? Only add values?
I thought use a Thread Pool
P.S. queue my implementation not stl
Bohdan
This second parameter put me in stupor
Bohdan
Yes, I implemented everything as you said.
But maybe the teacher meant that the threads would be implemented inside the function, this second parameter?
For exmp:
popFront(T key) {
std::thread thread ([&]() {
mutex.lock();
pop_front(key);
mutex.unlock();
});
thread.detatch();
}
}
And second parameter will be number of threads....its just a universe task,this stupid tasks
Bohdan
okey,thx so much
Brian
Program to find gross salary.
#include<stdio.h>
int main()
{
int gs,bs,da,ta;
printf(“enter basic salary: ”);
scanf(“%d”,&bs);
da=(10*bs)/100;
ta=(12*bs)/100;
gs=bs+da+ta;
printf(“gross salary=%d”,gs);
return 0;
}
😭😭where is the problem.... somebody pls
Mar!o
Hey guys, does anybody have experience using pthreads library? Does it work well for cross platform (Linux, Mac, Windows, Android, IOs) or should I write my own wrapper?!
Zel
Pthreads requires special libraries and reduces perfomance on windows machines
Mar!o
Well I would love to use C++ threads because I'm familiar with them but my program is written in C99 C 😅
YK Y
Zel
Might be a benefit to update that codebase.
Mar!o
Hmm I think I will go and create my own threading library then 😐
Mar!o
Maybe it's better anyways because I want full access and speed