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?

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’

In line 78 it was: sprintf(temp_out, "%d", cene);
Should be: sprintf(temp_out, "%d", cene);

In line 80 it was: write(pipa2[1], temp_out, 16);
Should be: write(pipa2[1], temp_out, 16);

In line 105 it was: sprintf(temp_out, "%d", cene);
Should be: sprintf(temp_out, "%d", cene);

In line 107 it was: write(pipa[1], temp_out, 16);
Should be: write(pipa[1], temp_out, 16);

If you look at the prototype of sprintf

int sprintf(char *str, const char *format, ...);

You'll note that the first argument is a char *str...your passing a character on line 78

sprintf(temp_out, "%d", cene);

temp_out is a character.

You might be able to get away with something like below where you'll pass the character array from address starting from temp_out.

sprintf(&temp_out, "%d", cene);

but I really doubt that's what your after.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.