|
What about a look at documentation [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Cedric Moonen wrote: If the application crashes...
What crash?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
That's why I said if . That was a guess from the symptoms if was describing: the application closes without notice and even puttin a system("pause") doesn't stop the windo to close. Sounds very close to a crash to me.
Anyway, using the debugger for such purpose (even if the application doesn't crash) brings much more info than trying to output text on the console trying to guess what is happening.
|
|
|
|
|
Cedric Moonen wrote: ...and even puttin a system("pause") doesn't stop the windo to close.
Most likely because LOG_INFO() and the subsequent call to system() are operating on two different command prompt windows. I don't see any way for the OP's current design to work.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
T.RATHA KRISHNAN wrote: system("PAUSE");
Why do you have to call system("pause") ? It is a very resource expensive call and is still not the fastest thing in the world. Can't you just use getch() or something else similar?
|
|
|
|
|
Rajesh R Subramanian wrote: Can't you just use getch() or something else similar?
I've used getchar(). But i didn't get the result. i.e I could not see my console's contents.(It doesn't pause). What else to do?
|
|
|
|
|
Is it C or C++? If it is C++, how about std::cin.get() ?
|
|
|
|
|
Rajesh R Subramanian wrote: If it is C++, how about std::cin.get()?
It's C++ only. I've just tested with this also(std::cin.get()). But I didn't get the result. Moreover, the output window displays "Native' has exited with code 3 (0x3)". Not the first time. When I try to use "system("PAUSE");", it displays the same message.
|
|
|
|
|
We're diggin' a deep hole. Let me ask you, What does "didn't get the result" mean? What are you expecting to achieve with system("pause") ?
|
|
|
|
|
Rajesh R Subramanian wrote: What are you expecting to achieve with system("pause")?
My application is running and it closes with out any notice. I want to display one message to the console before it closes. So I used system("PAUSE") command. It didn't work. What else to do?
|
|
|
|
|
As I already told you, if your application crashes you can't display anything in the console anymore. Why don't you learn to use your debugger properly ? It will save you a lot of time and headaches in the future and it is not very difficult to use.
To begin, simply press F5 to start your debugger. Normally, it will already point you to the crash location. You can still put breakpoints in your code (F9) to see the evolution.
Why not just experiment a bit with it ? It won't kill your PC and you will learn much more doing that than asking questions in a forum.
|
|
|
|
|
At first, the system("pause") caught my attention and therefore I replied. Now, you simply cannot output something "after" your program has crashed, because it is already dead. No matter what you do.
Please use the debugger, as Cedric already said.
|
|
|
|
|
Try executing this code from outside of the IDE, with a command prompt window already open.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all..
As i am new c# .net......I have created a structure in Dll and calling that DLL in vc++ console Application....
I am getting the structure variable in my console application...
when i put printf..I am able to see the values..
but when i save it in a text file i am getting buffer value ..
Actually i am trying with code..
<br />
const _TCHAR *elementName[100];<br />
const _TCHAR *elementValue[100];<br />
Sharepoint_API::StructGetSite HUGEP *pBSTR; <br />
hr = SafeArrayAccessData(pICalc->GetData, (void HUGEP* FAR*)&pBSTR); <br />
for(i=0; i<pBSTR[0].totAttribute; i++){<br />
elementName [i] = "NAME";<br />
elementValue[i] = (LPCTSTR)pBSTR[i].Atrribute; <br />
printf("%d. is %S \n", i+1, elementValue[i]);<br />
ofstream TestFile("E:\\Test.txt",ios::app);<br />
if(TestFile) <br />
{<br />
TestFile<<elementValue[i];
}<br />
else if(!TestFile) <br />
{<br />
}<br />
TestFile.close();
In printf I am getting the correct value...
but in text file i am getting "h"
pBSTR[0].totAttribute is the total count i am getting from structure from dll
thank you....very much..
manju
Hi..
I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++
manju
|
|
|
|
|
Probably you've to replace
TestFile << elementValue[i];
with
TestFile.write( (const char*) elementValue[i], _tcslen(elementValue[i])*sizeof(TCHAR));
since even a wostream would not do the trick.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Sorry sir...
not working..
yet the same result..
I am getting output as
hhhhh
Hi..
I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++
manju
|
|
|
|
|
What's the input, instead?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: What's the input, instead?
Actually i will get the sharepoint folders which are stored in structures in the dll...
Actually i must get
/////////////////////////////
http://sharepoint/Docs
http://sharepoint/News
http://sharepoint/Reports
http://sharepoint/SearchCenter
http://sharepoint/SiteDirectory
/////////////////////////////
when i put printf
i.e printf("%d. is %S \n", i+1, elementValue[i]);
I am getting the value for elementValue[i]
Hi..
I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++
manju
|
|
|
|
|
If you need to write a UNICODE file the code I provided works fine but you have to put the proper BOM at the very start of the file, for instance
TCHAR * szIn = _T("http://sharepoint/Docs");
ofstream of("foo.txt", ios::out);
#ifdef _UNICODE
TCHAR BOM = 0xFEFF;
of.write((const char *) &BOM, sizeof(TCHAR));
#endif
of.write((const char *) szIn, _tcslen(szIn)* sizeof(TCHAR));
of.close();
On the other hand, if you need to write a ANSI file then follow Naveen suggestion: use wofstream instead of ofstream.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Rajesh R Subramanian wrote: [Suspicious]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hint: That's just not an emoticon, it is a hyperlink, in my previous post.
A post of mine is downvoted for no good reason (IMHO) in that thread. So, superhero intervention needed.
|
|
|
|
|
Rajesh R Subramanian wrote: That's just not an emoticon, it is a hyperlink, in my previous post.
OMG: I'm Mr.Dumb (drugz, maybe?).
BTW: balanced.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: BTW: balanced.
Thanks, Mr.Dumb.
|
|
|
|