I have a problem when I try to compile my code. Sorry in advance for non-english language in code..
npipe.c:78: warning: passing argument 1 of ‘sprintf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘char * __restrict__’ but argument is of type ‘char’
npipe.c:80: warning: passing argument 2 of ‘write’ makes pointer from integer without a cast
/usr/include/unistd.h:363: note: expected ‘const void *’ but argument is of type ‘char’
npipe.c:105: warning: passing argument 1 of ‘sprintf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘char * __restrict__’ but argument is of type ‘char’
npipe.c:107: warning: passing argument 2 of ‘write’ makes pointer from integer without a cast
/usr/include/unistd.h:363: note: expected ‘const void *’ but argument is of type ‘char’
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv)
{
char temp_in[16]="";
char temp_out[16];
int pipa[2];
int pipa2[2];
int pipa3[2];
int cene[50];
int cena = 0;
int i = 0;
pid_t pid;
if (argc==1)
{
printf("Podaj vhodni-e element-e!\n");
}
else
{
int st_izdelkov=argc-1;
if(pipe(pipa) == -1)
{
perror("pipe call error");
_exit(1);
}
if(pipe(pipa2) == -1)
{
perror("pipe call error");
_exit(1);
}
if(pipe(pipa2) == -1)
{
perror("pipe call error");
_exit(1);
}
pid=fork();
if(pid==0) /*proizvajalec*/
{
for( i=0;i<st_izdelkov;i++)
{
cena=atoi((argv[i+1]));
printf("Cena %d pri proizvajalcu: %d\n", i+1, cena);
cene[i+1]=cena;
close(pipa[0]);
write(pipa[1], argv[i+1], 16);
}
exit(EXIT_SUCCESS);
}
else /*distributer*/
{
wait(&pid);
pid=fork();
if(pid==0)
{
for(i=0;i<st_izdelkov;i++)/*branje in izpisovanje distributerja*/
{
close(pipa[1]);
read(pipa[0], temp_in,16);
cene[i]=atoi(temp_in);
cene[i]+=(cene[i]*0.2);
printf("Cena %d pri distributerju: %d\n", i+1, cene[i]);
}
for(i=0; i<st_izdelkov;i++) /*pošiljanje tgovcu*/
{
sprintf(temp_out[i], "%d", cene[i]);
close(pipa[0]);
write(pipa2[1], temp_out[i], 16);
}
close(pipa[1]);
exit(EXIT_SUCCESS);
}
else/* trgovec */
{
wait(&pid);
pid=fork();
if(pid==0)
{
for(i=0; i<st_izdelkov;i++)/*branje in izpisovanje pri tgovcu*/
{
close(pipa2[1]);
read(pipa2[0], temp_in, 16);
cene[i]=atoi(temp_in);
cene[i]+=(cene[i]*0.3);
printf("Cena %d pri trgovcu: %d\n", i+1, cene[i]);
}
for(i=0; i<st_izdelkov;i++) /*pisanje pri potrosniku*/
{
sprintf(temp_out[i], "%d", cene[i]);
close(pipa2[0]);
write(pipa[1], temp_out[i], 16);
}
exit(EXIT_SUCCESS);
}
else/* POTROSNIK */
{
wait(&pid);
pid=fork();
if(pid==0)
{
for(i=0; i<st_izdelkov;i++)/*branje in zpisovanje pri potrošniku*/
{
close(pipa[1]);
read(pipa[0], temp_in, 16);
cene[i]= atoi(temp_in);
printf("Cena %d potrosnika: %d\n", i+1, cene[i]);
}
exit(EXIT_SUCCESS);
}
}
}
}
}
return EXIT_SUCCESS;
}
Any ideas?