Sorry for messing you all with the C stuff.
The write() takes void * buff. And i need to call this function from main() by giving the required data.
But when i am printing it throws an error. Help me out friends.
Code is as follows.
void write(int fd, void *buff,int no_of_pages)
{
// some code that writes buff into a file using system calls
}
Now i need to send the buff with the data i need.
#include "stdio.h"
#include "malloc.h"
int main()
{
int *x=(int*)malloc(1024);
*(x+2)=3192;
*(x+3)="sindhu";
printf("\n%d %s",*(x+2),*(x+3));
write(2,x,10); //(10=4bytes for int + 6 bytes for char "sindhu");
}
It warns me
warning: format ‘%s’ expects type ‘char *’, but argument 3 has type ‘int’
How can i remove this warning
By casting to a valid type:
Note: What you’re doing looks evil. I’d reconsider this design!