Re: How it works?



On 29 Apr 2006 16:36:10 -0700, "Mohan" <mohan.smvec@xxxxxxxxx> wrote:

Hi Friends,
The following code is working fine and printing the string "Mohan S".

#include<stdio.h>
int main()
{
FILE *fp;
fp=stdout;
fprintf(fp,"%s","Mohan S");
}

My doubt is how it is possible to assign a standard output stream to a
file stream....Why it didn't throw any error;instead its running
fine...

Can anyone give me clear explanations... ?
Thanks in advance...
stdout is a FILE* that is declared in stdio.h and defined and
initialized by the startup code that executes prior to main. fp is a
FILE* defined in your program. It is perfectly legal for two pointers
to point to the same object.



Remove del for email
.



Relevant Pages

  • Re: How it works?
    ... The following code is working fine and printing the string "Mohan S". ... int main ... My doubt is how it is possible to assign a standard output stream to a ...
    (comp.lang.c)
  • How it works?
    ... The following code is working fine and printing the string "Mohan S". ... int main ...
    (comp.lang.c)
  • Re: Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... conformant string. ... int repeats, reps; ... ref satisfierLength); ...
    (comp.programming)
  • RE: Controling Modal Dialogs (Solution)
    ... doesn't return until the 'modal' browser returns. ... string varOptions) ... public void DocumentComplete ... int rc = winDisp.Invoke(rgDispId, ref guid, 0, ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Gcc compatible header file
    ... A string collection is a table of zero terminated strings that will grow ... typedef struct _StringCollection StringCollection; ... int; ... bool; ...
    (comp.lang.c)