Search Results

Search: Posts Made By: giampoul
Forum: Programming 02-08-2016
7,005
Posted By jim mcnamara
There is more to this than just one small example...
There is more to this than just one small example of code can fix. I found a pretty complete discussion here. READ the whole thing because there are several gotchas.
Try:


Malloc and MPI...
Forum: Programming 05-23-2012
4,389
Posted By shamrock
The 8085 uses 2s complement to represent negative...
The 8085 uses 2s complement to represent negative numbers...so knowing that negate i^2 by inverting it and adding 1 to it followed by adding 1 again to represent the equation "n=1-i^2"...and in the...
Forum: Programming 05-15-2012
4,389
Posted By shamrock
As the 8085 doesnt have a multiply instruction...
As the 8085 doesnt have a multiply instruction you will have to add i to itself i times every time you go throgh the loop...here is a sample routine when i==3...

MVI B,03H
MVI A,0H
MOV...
Forum: Programming 04-18-2012
1,515
Posted By migurus
These macros are used to check process status....
These macros are used to check process status. The pclose() call does report exit status of the process which has been run by corresponding popen().


int rc;
rc = pclose(pfp);...
Forum: Programming 04-16-2012
1,515
Posted By migurus
don't forget to use W macros (WEXITSTATUS ,...
don't forget to use W macros (WEXITSTATUS , etc...) when checking return status of pclose
Forum: Programming 04-12-2012
1,515
Posted By Corona688
Because it's completely possible for a program to...
Because it's completely possible for a program to print more than one line. ;) fgets() just reads the lines one at a time. Inside the loop, you can use the contents of the line as you see fit.
...
Forum: Programming 04-12-2012
1,515
Posted By Corona688
char buf[512]; FILE *fp=popen("ls -l", "r"); ...
char buf[512];
FILE *fp=popen("ls -l", "r");

while(fgets(fp, 512, fp))
{
...
}

pclose(fp);
Forum: Programming 03-31-2012
2,003
Posted By CarloM
na and sur are not type char - they're char...
na and sur are not type char - they're char pointers to 20 bytes of memory.
Forum: Programming 03-31-2012
2,003
Posted By shamrock
You cant do free(Stus.arr) because Stus is now a...
You cant do free(Stus.arr) because Stus is now a type...first you have to create an object of type Stus...
Stus x;
Now you can refer to to its member arr using this...
free(x.arr)
Forum: Programming 03-28-2012
15,891
Posted By agama
No, you cannot just place it into a loop because...
No, you cannot just place it into a loop because there is no way to 'mark' the buffer and start sscanf where it left off. You can do something like this:



#include <string.h>
#include...
Forum: Programming 03-23-2012
3,922
Posted By Corona688
They were probably making an array of pointers to...
They were probably making an array of pointers to strings.
Forum: Programming 03-23-2012
15,891
Posted By agama
Great progress! You need to correct a few...
Great progress!

You need to correct a few things if you haven't.

First, the warning about %s in conjunction with strerror() is because you haven't included string.h. The strerror() function...
Forum: Programming 03-22-2012
3,922
Posted By Corona688
I found another problem: You're allocating...
I found another problem:

You're allocating size*sizeof(struct shop *).

What is a shop *? It's a pointer -- something like an integer, to hold one single memory address. It might be 4 bytes,...
Forum: Programming 03-22-2012
3,922
Posted By Corona688
Windows can let you get away with some very silly...
Windows can let you get away with some very silly things -- for a while. In my early programming days I wrote a music player that crashed on quit, and I couldn't figure out why until I rewrote it...
Forum: Programming 03-20-2012
15,891
Posted By agama
Because your parent process waits for the child...
Because your parent process waits for the child to exit, all data will be read into the buffer, and you'll need to pull all of the values out in a single sscanf() call.

Something like this:


...
Forum: Programming 03-20-2012
15,891
Posted By shamrock
See my comments in red above...it needs more...
See my comments in red above...it needs more fixes but that is left as an exercise for the op...
Forum: Programming 03-18-2012
15,891
Posted By agama
I've made changes to your code, and have a...
I've made changes to your code, and have a working copy. I'll post my comments so if you want to work the changes yourself you can; I can post the code if you'd rather me do that.

In no real...
Forum: Programming 03-14-2012
15,891
Posted By shamrock
There are many things wrong with the pipe and...
There are many things wrong with the pipe and array code...not initalizing m[4] to 0 before using it in the addition and in the parent you are not reading the value into c[i][j] but instead putting...
Forum: Programming 03-14-2012
15,891
Posted By agama
Only have time for a quick look, but this is what...
Only have time for a quick look, but this is what jumped out at me:

Write is not like printf(), it takes a buffer of data and a length and doesn't do any formatting. You had the right idea in...
Forum: Programming 03-13-2012
15,891
Posted By agama
First, move your initialisation of m to the start...
First, move your initialisation of m to the start of the loop:



for(j=0;j<4;j++)
{
m = 0;
for(n=0;n<3;n++)
{
m=m+a[i][n]*b[n][j];
}
c[i][j]=m;
}
...
Forum: Programming 12-05-2011
3,321
Posted By Corona688
As explained many times in the last 2 pages, that...
As explained many times in the last 2 pages, that sets all three arrays to the SAME MEMORY. It doesn't matter where you put that wrong code, it doesn't make it right code.

int *A=shmat(...);
int...
Forum: Programming 12-05-2011
3,321
Posted By Corona688
You use a(i,j) in many places you should be using...
You use a(i,j) in many places you should be using A(i,j).
Forum: Programming 12-05-2011
3,321
Posted By Corona688
That's mutually exclusive. If they're fixed...
That's mutually exclusive.

If they're fixed in size, they don't change and therefore can't be set at runtime.

That won't work. l, m, n have to be constant numbers. That's why I asked whether...
Forum: Programming 12-05-2011
3,321
Posted By Corona688
Well, it depends... Are these arrays going to...
Well, it depends... Are these arrays going to change in size, at all, ever? Or are they going to be a fixed size, forever?

If they're going to be the same size forever, you can do this:
struct...
Forum: Programming 12-05-2011
3,321
Posted By Corona688
It's the same as B = A + (3*2). Just reusing my...
It's the same as B = A + (3*2). Just reusing my code. shmat() always gives you the same memory for the same ID -- that's what lets you share it between processes, you get the same memory.

//...
Showing results 1 to 25 of 38

 
All times are GMT -4. The time now is 02:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy