By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,784 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,784 IT Pros & Developers. It's quick & easy.

error: invalid type argument of unary ‘*’ (have ‘int’)

P: 1
Expand|Select|Wrap|Line Numbers
  1. char *chktype(char *Buffer, int Size)//checks the Content-Type and gives extension
  2.         {
  3.             unsigned short iphdrlen;
  4.         struct iphdr *iph = (struct iphdr *)( Buffer  + sizeof(struct ethhdr) );
  5.         iphdrlen = iph->ihl*4;
  6.         struct tcphdr *tcph=(struct tcphdr*)(Buffer + iphdrlen + sizeof(struct ethhdr));
  7.         int header_size =  sizeof(struct ethhdr) + iphdrlen + tcph->doff*4;
  8.  
  9.         char *strng = "Content-Type: ";
  10.         size_t sz;
  11.         char *found = strstr (Buffer + header_size, strng);
  12.         char *found1 = strstr(found, "\r\n");
  13.         sz=strlen(found)-strlen(found1);
  14.         char *type = malloc(sz+1);
  15.         strncpy(type, found, sz);
  16.         if (strncmp("Content-Type: text/html" , type, 23) == 0)
  17.         {
  18.         return(".html");
  19.         }
  20.         else
  21.         {
  22.         return("");
  23.         }
  24.     }
i am calling this function in the main as

Expand|Select|Wrap|Line Numbers
  1.     char *extension = chktype (buffer, size);
  2.                     printf("%s\r\n", extension);
but it gives me error

Expand|Select|Wrap|Line Numbers
  1.  Dummy.c:74:9: error: invalid type argument of unary ‘*’ (have ‘int’)
  2.     Dummy.c:76:5: warning: passing argument 1 of ‘chktype’ discards ‘const’ qualifier from pointer target type [enabled by default]
  3.     Dummy.c:22:7: note: expected ‘char *’ but argument is of type ‘const u_char *’
  4.     Dummy.c:78:5: warning: passing argument 1 of ‘chktype’ discards ‘const’ qualifier from pointer target type [enabled by default]
  5.     Dummy.c:22:7: note: expected ‘char *’ but argument is of type ‘const u_char *’
sorry for bad english, i am new to C, can anyone help. `buffer` is probly `const u_char *` type is this related in any way?? what is my mistake?? how can i get rid of error.?
Jun 27 '13 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
The type of your calling value has to match the type the function is expecting. The function expects a char* but you say you are probably using a u_char*.

That, in itself, won't work.
Jun 28 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.