Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Conversion: Totally newbie question

0 views
Skip to first unread message

Dimitri Kowaletschew

unread,
Dec 15, 2009, 3:42:12 AM12/15/09
to
Hello!

Can anybody please tell me how to do this correctly?

static int lCount;
lCount=lCount+1;

char sPath;
sPath="C:\\images\";
sPath = sPath + lCount;
sPath = sPath + ".jpg";

I am not knowingly using the framework (yet), just trying to get over
the first obstacles in my way.

Dimi

David Wilkinson

unread,
Dec 15, 2009, 8:32:11 AM12/15/09
to

Dimi:

Well, it depends what language you want to use

C
C++
C++/CLI

This newsgroup is intended for C++/CLI. If you want an answer for C or C++, a
better group is

microsoft.public.vc.language

or the MSDN forum at

http://social.msdn.microsoft.com/forums/en-US/vclanguage/threads/

In any case, I think you would benefit by reading a good introductory book on
your language of choice.

--
David Wilkinson
Visual C++ MVP

Dimitri Kowaletschew

unread,
Dec 15, 2009, 1:30:30 PM12/15/09
to
I didn't find that newsgroup :-(

Giovanni Dicanio

unread,
Dec 15, 2009, 1:41:45 PM12/15/09
to
"Dimitri Kowaletschew" <dim...@yahoo.com> ha scritto nel messaggio
news:edwKFTbf...@TK2MSFTNGP05.phx.gbl...

> I didn't find that newsgroup :-(

http://groups.google.com/group/microsoft.public.vc.language/topics

HTH,
Giovanni

Giovanni Dicanio

unread,
Dec 15, 2009, 2:01:42 PM12/15/09
to
"Dimitri Kowaletschew" <dim...@yahoo.com> ha scritto nel messaggio
news:uZtgVKWf...@TK2MSFTNGP02.phx.gbl...

I like CString class from ATL; you can use it both from pure Win32/C++ and
also in C++/CLI.
CString offers a method named Format, that you can use to format strings
like this:

CString strPath;
strPath.Format( TEXT("C:\\images\\%d.jpg"), lCount );

If you want to use .NET Framework's System::String class, you could find the
String::Format method useful:

String ^ s = String::Format("C:\\images\\{0}.jpg", lCount);

HTH,
Giovanni

Dimitri Kowaletschew

unread,
Dec 15, 2009, 3:05:50 PM12/15/09
to
Cool! Thanks a lot!!

Dimi

Dimitri Kowaletschew

unread,
Dec 15, 2009, 3:29:59 PM12/15/09
to
Somehow I cannot get it to compile, it's tell me that CString is an
undeclared identifier.
I tried
#include "string.h"
#include <string>

It seems that CString is only available with MFC which I didn't want to
include...

Isn't there any other way to combine the string with the number?

Dimi

Jason Newell

unread,
Dec 15, 2009, 3:59:20 PM12/15/09
to
It is available w/o MFC.

#include <atlstr.h>

Jason Newell
www.jasonnewell.net

Giovanni Dicanio

unread,
Dec 15, 2009, 4:49:12 PM12/15/09
to
"Dimitri Kowaletschew" <dim...@yahoo.com> ha scritto nel messaggio
news:O4S82Vcf...@TK2MSFTNGP05.phx.gbl...

> Somehow I cannot get it to compile, it's tell me that CString is an
> undeclared identifier.
> I tried
> #include "string.h"
> #include <string>
>
> It seems that CString is only available with MFC which I didn't want to
> include...

CString was an MFC class with Visual C++ 6, but with VS.NET 2003 (a.k.a.
VC7.1) CString was factored out of MFC and was made available also for
non-MFC projects. In fact, CString is now an ATL class.

If you read CString documentation on MSDN:

http://msdn.microsoft.com/en-us/library/5bzxfsea.aspx

you can find that the header file required for using CString in non-MFC
projects is <atlstr.h>, as Jason Newell already pointed out.

The <string> standard header file is for STL's std::[w]string class (not for
CString)

http://msdn.microsoft.com/en-us/library/syxtdd4f.aspx

If your project is built using precompiled headers, you may want to add
#include <atlstr.h> in your "StdAfx.h" header file.

Giovanni

Dimitri Kowaletschew

unread,
Dec 16, 2009, 1:05:29 AM12/16/09
to
Thank you very much!

Dimi

0 new messages