|
Ive been stuck on this problem for ages and it wasnt much help before so will try again being the n00b I am lol
i have
TCHAR szBuf[100];
INT i,j,k;
i=1;
j=2;
k=5;
_stprintf(szBuf, "%d %d %d", i, j, k);
SetWindowText(hWnd, szBuf);
it cant find _stprintf, keeps saying undefined no matter what header file i include, can someone please help me sort this out, its driving me insane
|
|
|
|
|
Have you included TCHAR.H ?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Interesting that the compiler knows what a TCHAR is but doesn't
recognize that function if you haven't #included tchar.h
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i did include TCHAR.h etc but it still omplained about the _stprintf which is what i dont get, it was saying it was undeclared yet the file was included and the include file didnt cause any errors
|
|
|
|
|
What Visual Studio version are you using?
On VS2008, this compiles for me (aside from the warning
for using an unsafe CRT function)...
#include <tchar.h>
void SomeFunc()
{
TCHAR szBuf[100];
int i,j,k;
i=1;
j=2;
k=5;
_stprintf(szBuf, _T("%d %d %d"), i, j, k);
}
Mark Salsbery
Microsoft MVP - Visual C++
modified on Monday, October 13, 2008 12:08 AM
|
|
|
|
|
Mark Salsbery wrote: On VS2008, this compiles for me (aside from the warning
for using an unsafe CRT function)...
Same here with VS2005. I added the code to an existing dialog-based project and it compiled fine. No additional header files were added.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thanks for the heads-up - I forgot to change the <>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Are you including stdio.h ?
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]
|
|
|
|
|
i did include that but it came up with similar error, cant remember if it was a crt error though should those just be ignored,
anyway im using visual studio 2005
|
|
|
|
|
You need both TCHAR.h and stdio.h . Try to include these files and if you get any error post the complete error message here.
Nevermind, I was wrong about (as Mark [^] pointed out).
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]
modified on Monday, October 13, 2008 1:51 AM
|
|
|
|
|
CPallini wrote: You need both TCHAR.h and stdio.h
Nah Maybe in VC6...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Nah
You're right.
Mark Salsbery wrote: Maybe in VC6...
Nope. Also VC6 compiles fine with TCHAR.h alone.
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]
|
|
|
|
|
Hi all,
I want to create a file in vista(UAC Enabled) using CreateFile() API. But the problem is its not creating the file. Using GetLastError() is returning 5. How can i create the file in vista(UAC Enabled).
Thanks in advance..
|
|
|
|
|
You are probably trying to create the file in the same folder as your application (which is in Program Files). Under Vista, this requires admin privilege.
Instead you should store your data in the appdata folder. Take a look at SHGetFolderPath[^] using the CSIDL of CSIDL_APPDATA or CSIDL_LOCAL_APPDATA.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
If you take a look at the System Error Codes, error code 5 is ERROR_ACCESS_DENIED , which means what it says on the tin.
If you are writing to a restricted directory, you will need to elevate your process prior to writing to it.
Regards,
--Perspx
"I've got my kids brainwashed: You don't use Google, and you don't use an iPod." - Steve Ballmer
"Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen an angry penguin charging at them in excess of 100mph." - Linus Torvalds
|
|
|
|
|
#pragma check_stack([ {on | off}] ) is used to know stack overflow. How it will report stack overflow ? I tried with on and off switch for a function f1(). it gives same error.
How and where this pragma can be useful ?
#pragma check_stack(on) // Tried with both on and off . both gives stack overflow.
__int64 f1(__int64 a);
__int64 f1(__int64 a)
{
if((a-1)==0)
return 1;
return a*f1(a-1);
}
int main()
{
printf("\nInside Main");
printf("\n%ld\n",f1(99999));
}
|
|
|
|
|
You're going to get a stack overflow no matter what settings you use.
That isn't something that can just be reported. There's no safe way
for the process to continue.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Thanks for responding.
But than why this #pragma check_stack exsists ? what is the use of this ?
Alok
|
|
|
|
|
Alok Chauhan wrote: why this #pragma check_stack exsists ?
To control stack probing (see /Gs (Control Stack Checking Calls)[^]).
This applies to stack frames[^] set up for function calls, not to recursive
function calls running off the end of the stack.
As mentioned in the /Gs docs (linked to above), you need a stack frame for a given
function that is at least 4KB (on x86 platform) for stack probing to have an effect.
Try changing your function to make a big stack frame and you'll see - it will
still fault because of the recursion, but it will happen in the stack probing code when
there's no more stack to automagically allocate for the function call:
#pragma check_stack(on)
_int64 f1(__int64 a)
{
char arr[5000];
if((a-1)==0)
return 1;
return a*f1(a-1);
}
This is a pretty advanced topic, and the default settings work
well for Windows - what are you trying to do?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Please send to me a Btree library which written by C++ or C#. I need it for my program. Thanks. My email phap007@yahoo.com
|
|
|
|
|
|
plz send me money or drugz: me@cpallini.com
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]
|
|
|
|
|
Why I must be give you money when I can use of your site freely?
|
|
|
|
|
Shhhhhhhhhhhhhhh!
You're such a smart guy, Hamid.
BTW welcome in THHB (T hread H ijacking H appy B rigade)
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 welcome in THHB (Thread Hijacking Happy Brigade)
You and me and Rajesh I think ,btw you invited me previous do you remember?
|
|
|
|