Sponsored Content
Top Forums Programming warning: passing arg 1 of `inet_addr' makes pointer from integer without a cast Post 302379510 by konvalo on Friday 11th of December 2009 01:40:47 AM
Old 12-11-2009
Question warning: passing arg 1 of `inet_addr' makes pointer from integer without a cast

I use solaris10,following is tcp client code:
Code:
#include "cliserv.h"
int main(int argc,char argv[]){
  struct sockaddr_in serv;
  char request[REQUEST],reply[REPLY];
  int sockfd,n;
  if(argc!=2)
    err_quit("usage: tcpclient <IP address of server>");
  if((sockfd=socket(PF_INET,SOCK_STREAM,0))<0)
    err_sys("socket error");
  memset(&serv,0,sizeof(serv));
  serv.sin_family=AF_INET;
  serv.sin_addr.s_addr=inet_addr(argv[1]);
  serv.sin_port=htons(TCP_SERV_PORT);
  if(connect(sockfd,(SA)&serv,sizeof(serv))<0)
    err_sys("connect error");
  if(write(sockfd,request,REQUEST)!=REQUEST)
    err_sys("write error");
  if(shutdown(sockfd,1)<0)
    err_sys("shutdown error");
  exit(0);
}

when I compile it,it raise following warning:
$gcc -lsocket -lnsl tcpclient.c -o tcpclient
tcpclient.c: In function `main':
tcpclient.c:12: warning: passing arg 1 of `inet_addr' makes pointer from integer without a cast

When I execute it,it raise following error:
$tcpserver &
$tcpclient 127.0.0.1
Segmentation Fault (core dumped)

How to correct above error? How to modify "tcpclient.c:12: warning: passing arg 1 of `inet_addr' makes pointer from integer without a cast"?

Thanks
 

10 More Discussions You Might Find Interesting

1. Programming

Will we get SEGV if we try to “delete []” un-initialized integer pointer variable.

I have a class with an integer pointer, which I have not initialized to NULL in the constructor. For example: class myclass { private: char * name; int *site; } myclass:: myclass(....) : name(NULL) { ..... } other member function “delete “ the variable before... (2 Replies)
Discussion started by: sureshreddi_ps
2 Replies

2. Shell Programming and Scripting

cat behavior when passing http prams as arg

Hello all im newbie in unix , as my experiences i passed to the cat utility http prams as args i got : cat http://localhost:8000/test.php? szAddress=&szNationalId=&szFirstName=&szLastName=&undefined=undefined&iTargetModule=0&bFullScreen= and the result is : 2540 3016 2356 2552 ... (0 Replies)
Discussion started by: umen
0 Replies

3. Programming

comparison between pointer and integer

I received a warning when I tried to compile my program that said: warning: comparison between pointer and integer Could you please explain to me what this means, and in what ways I could possibly fix this? Thanks for your help! (2 Replies)
Discussion started by: sjung10
2 Replies

4. Programming

`strcat' makes pointer from integer without a cast

A question to ask. seq1 = "eeeeeeeeeeeeeeeeee"; seq2 = "dddddddddddddddddddd"; char a = '*'; strcat(*seq2, &a); strcat(*seq1, seq2); compilation warning: passing arg 1 of `strcat' makes pointer from integer without a cast thanks (4 Replies)
Discussion started by: cdbug
4 Replies

5. Programming

warning: int format,pid_t arg (arg 2)

I try following code under Solaris10,like follows: int glob = 6; int main(void) { int var; pid_t pid; var = 88; printf("before vfork\n"); if ((pid = vfork()) < 0) { err_sys("vfork error"); } else if (pid == 0) { glob++; var++; _exit(0); } ... (1 Reply)
Discussion started by: konvalo
1 Replies

6. Shell Programming and Scripting

passing integer in getopts

Hi, I'm writing a shell script where I need to parse the command line arguments using "getopts" command. While using getopts I need to know how to pass numeral values to getopts. For example: while getopts ":h" Option do case $Option in h ) display_help;; ... (5 Replies)
Discussion started by: arun_maffy
5 Replies

7. Programming

warning: comparison between pointer and integer

Hi guys :D I am still playing with my C handbook and yes, as you can see I have small problem as always :cool: I wrote a C code #include <stdio.h> #define MESSAGE 100 int main(void) { char input_mes - Pastebin.com And when I try to compile it I get following errors from gcc ... (1 Reply)
Discussion started by: solaris_user
1 Replies

8. UNIX for Dummies Questions & Answers

Counting vowels in string. "Comparison pointer-integer".

I'm trying to write a programme which scans strings to find how many vowels they contain. I get an error saying that I'm trying to compare a pointer and an integer inif(*v == scanme){. How can I overcome this ? Also, the programme seems to scan only the first word of a string e.g.: if I type "abc... (1 Reply)
Discussion started by: fakuse
1 Replies

9. Shell Programming and Scripting

Passing argument 1 of 'scanf' makes po

$ cc Array.c Array.c: In function ‘main’: Array.c:23: warning: passing argument 1 of ‘scanf’ makes po Array.c:25: error: expected expression before ‘return’ Array.c:29: error: expected expression before ‘return’ Array.c: At top level: Array.c:44: error: expected ‘)’ before ‘&’ token... (8 Replies)
Discussion started by: sgradywhite
8 Replies

10. Programming

Warning: pointer type mismatch

Hi all, I'm new programming in C, so I had the next message in my code: Dual.c:88:20: warning: pointer type mismatch in conditional expression : &clientSa.sin6.sin6.sin6_addr, Any help would be great #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include... (1 Reply)
Discussion started by: godna
1 Replies
Tk_GetScrollInfo(3)					       Tk Library Procedures					       Tk_GetScrollInfo(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_GetScrollInfo, Tk_GetScrollInfoObj - parse arguments for scrolling commands SYNOPSIS
#include <tk.h> int Tk_GetScrollInfo(interp, argc, argv, dblPtr, intPtr) int Tk_GetScrollInfoObj(interp, objc, objv, dblPtr, intPtr) ARGUMENTS
Tcl_Interp *interp (in) Interpreter to use for error reporting. int argc (in) Number of strings in argv array. const char *argv[] (in) Argument strings. These represent the entire widget command, of which the first word is typically the widget name and the second word is typically xview or yview. int objc (in) Number of Tcl_Obj's in objv array. Tcl_Obj *const objv[] (in) Argument objects. These represent the entire widget command, of which the first word is typically the widget name and the second word is typically xview or yview. double *dblPtr (out) Filled in with fraction from moveto option, if any. int *intPtr (out) Filled in with line or page count from scroll option, if any. The value may be negative. _________________________________________________________________ DESCRIPTION
Tk_GetScrollInfo parses the arguments expected by widget scrolling commands such as xview and yview. It receives the entire list of words that make up a widget command and parses the words starting with argv[2]. The words starting with argv[2] must have one of the following forms: moveto fraction scroll number units scroll number pages Any of the moveto, scroll, units, and pages keywords may be abbreviated. If argv has the moveto form, TK_SCROLL_MOVETO is returned as result and *dblPtr is filled in with the fraction argument to the command, which must be a proper real value. If argv has the scroll form, TK_SCROLL_UNITS or TK_SCROLL_PAGES is returned and *intPtr is filled in with the number value, which must be a proper integer. If an error occurs in parsing the arguments, TK_SCROLL_ERROR is returned and an error message is left in interp->result. Tk_GetScrollInfoObj is identical in function to Tk_GetScrollInfo. However, Tk_GetScrollInfoObj accepts Tcl_Obj style arguments, making it more appropriate for use with new development. KEYWORDS
parse, scrollbar, scrolling command, xview, yview Tk 8.0 Tk_GetScrollInfo(3)
All times are GMT -4. The time now is 04:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy