Re: difference between typedef and #define

Tech-Archive recommends: Fix windows errors by optimizing your registry



Drew Myers wrote:
> [...]
> But if I, without using typedef or #define write:
>
> int* i,j,k; // * next to int and not next to i
>
> all of the variables are int*, whereas:
>
> int *i,j,k; // * next to i and not next to int
>
> produces the results you explain. Why does typedef/#define
> behave differently than typing it out as I did above?

It doesn't. _You_ are mistaken. The two operators you wrote behave
in _exactly_the_same_way_: the 'i' gets the type 'int*', the rest of
them get the type 'int'.

V


.



Relevant Pages

  • Bypassing Personal Firewalls
    ... typedef SOCKET (int, int, int); ... typedef int (__stdcall *func_connect)(SOCKET, const struct sockaddr ... typedef HANDLE (LPCTSTR, DWORD, DWORD, ...
    (Bugtraq)
  • Bypassing Personal Firewalls
    ... typedef SOCKET (int, int, int); ... typedef int (__stdcall *func_connect)(SOCKET, const struct sockaddr ... typedef HANDLE (LPCTSTR, DWORD, DWORD, ...
    (Vuln-Dev)
  • Re: formal parameter 1 different from declaration?
    ... Here is the typedef one: ... typedef LR (HWND, long, int, int); ... struct tagWnd; // forward declaration ... takes a struct tagHwnd and the other takes a long. ...
    (microsoft.public.vc.language)
  • Re: I dont understand typedef example
    ... * Using typedef, declare 'func' to have type ... 'function taking two int arguments, ... declared ptr as a pointer object that can points to a function of the ...
    (comp.lang.c)
  • Re: I dont understand typedef example
    ... Using typedef, declare 'func' to have type ... 'function taking two int arguments, ...
    (comp.lang.c)