Thanks buddy, I was missing a fclose().
Thanks a lot! :)
Type: Posts; User: DeanWinchester
Thanks buddy, I was missing a fclose().
Thanks a lot! :)
Hello Jim, thanks for your reply.
I'm well aware but fscanf is working, as I've mentioned in the first post, it's working and creating the textfiles, it's only doing that when I compile the...
I managed to find out that when he reads the file, this file is empty.
Is there any way I can refresh a folder in C?
Hello everyone, I might be need your help in a thing that has been bothering me.
I have a function called map() that creates a file called 'merdas.txt' and writes to it.
After that, I call a...
Alright, my mate managed to get it working!
Thanks so much! :)
Thanks.
It's printing the pids as following :
pid: 1355
pid: 0
pid: 0
On the father, it's already reading two lines from the the exec output :
My whole function right now looks like this :
void map(char* cmd, char* arg){
int i;
int d=0;
int pid = fork();
FILE *stream;
int status;
I don't think the child is going to the father process.
What I think and know is my program isn't entering here :
else if (pid==0)
{
dup2(fd[1],1);
printf("son\n");
...
Yes, I did change it to that and still it ain't working.
I completely have no idea why he just doesn't enter the son part instead of the dad part .. :/
I've sorted my types out, thanks.
Hmm, so having the child pid 0 where should I have my waitpid ?
I need it to enter the son first :
if(pid==0) // filho
Doing instead
waitpid(-1, status, 0);
Managed to cut the error out but still it won't work >_>
cc1: warnings being treated as errors
soluis2.c: In function ‘map2’:
soluis2.c:93: warning: format ‘%s’ expects type ‘char *’, but argument 4 has type ‘char (*)[1000]’
soluis2.c:93: warning:...
Thanks for the kind replies and explanation.
I found out what's happening, I just do not know how to solve it.
Thing is my wait function isn't working, this :
else
waitpid(-1,...
I've changed my whole function.
It looks like this now :
void map(char* cmd, char* arg){
int i;
int d=0;
int pid;
FILE *stream ;
Done aswell, thanks for the tip.
Here it is Salem :
void map(char* cmd, char *arg){ int i;
int pid;
int fd[2];
char* buffer;
char* novo;
int status;
Tried that.
After
read(fd[0],buffer,strlen(arg));
I have this printf :
Hello everyone,
I'm trying to communicate between father and son processes using pipes.
Wouldn't this be the proper way for the son to communicate with his father ?
else if(pid==0) {
Hello guys,
my input on the terminal should be something like this :
./mapreduce du "wc -l"
In which du is the map argument and "wc -l" is reduce's argument.
Declared str as static and worked just fine.
Thanks bud!
Hello everyone,
I'm trying to return a string to then call it on main function.
My code is the following :
const char* coiso(int chave){
char str [50];
sprintf(str,"%d",chave);
Thanks so much.
You're the best guy ever.
You're best than my teachers, you explain everything so detailed! :)
Now what I want to do is :
I want to read line by line.
After reading the first line,
I should read until the number is over and when this is done I should add the number to the key field in the...
72 .
16 ./.DS_Store
8 ./a
8 ./lerficheiro.c
8 ./o
24 ./so
8 ./so.c
File '/Users/machd/Desktop/SistemasOperativos2013/GuardaLinhas/merdas.txt' read successfully.
Thanks sir, worked just fine.
Hmm, understood.
Thanks so much.
Well, what's inside.
I got this piece of code to read what's inside the text file :
while(!feof(fp)){
fgets(buffer,200,fp);