Note that there are some explanatory texts on larger screens.

plurals
  1. POStream (pointer to a file structure) in File handling giving strange values
    primarykey
    data
    text
    <p>i am trying to output a buffer to a file using visual c++. my code for doing it is-</p> <pre><code>FILE *stream; stream=fopen("C:\\Users\\sshekha\\Desktop\\z.txt","r"); //I also tried with "w" mode //the differencein behavious on executing these two is that when it is in read mode it //executes the else condition in the code below whereas in "w" mode it executes the "if" // condition, //moreover even if i change the path it don't execute the "else" condition-that means this path //is effective to the code. and the another surprising thing is when i open the file manually // and then run the code with "r" mode it still executes the "else" part (which it shouldn't // because the file is already open.) if( stream == 0 ) { MessageBox(m_hwndPreview,L" the file is not opened ",L"BTN WND",MB_ICONINFORMATION); } else { MessageBox(m_hwndPreview,L" the file is opened ",L"BTN WND",MB_ICONINFORMATION); int check=fputs (HtmlFileContents,stream); fclose(stream); return 0; } </code></pre> <p>I tried to check the results using different mode in order to understand whats teh probem going on . when i debug it , i get the value of (in Read mode) :</p> <blockquote> <p>stream = 0x000000005c5c76f0 { _ptr=0x0000000000000000 _cnt=0 _base=0x0000000000000000 ...}</p> </blockquote> <p>I don't know it gib=ves bad pointer and even then it go to else part of the loop. Why ?</p> <p>and in write mode </p> <blockquote> <p>stream = 0x0000000000000000 {_ptr=??? _cnt=??? _base=??? ...}</p> </blockquote> <p>So go to the if part of the loop.</p> <p>Moreover my path is correct and i have enough permission to do the task I wish. But why does it give bad pointer ? Why have I these strange values of stream and what should I do to copy the content of my buffer <code>HtmlFileContents</code> in to <code>z.txt</code> ? Any ideas ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload