|
You can use _tcscpy which will be either strcpy or wcscpy , depending on _UNICODE .
|
|
|
|
|
As Rage mentioned....all the CRT string functions have a generic equivelant.
Here's a handy chart: Routine Mappings[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am extremely sorry if this is not the correct forum to post this question.
Conditional break point on CString object is not working, while i have checked that with int datatype and it was working fine, and evaluating the condition correctly.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language; please excuse any grammatical or spelling mistakes"
|
|
|
|
|
Possibly it's evaluating the address of the CString which likely isn't changing. I suggest putting the breakpoint in the CString code itself if you want to catch a CString changing. You could even make that breakpoint conditional on the internal buffer contents to get straight to the one you want. CString itself is a wrapper around a character buffer which is where the change is that it looks like you want to catch.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hello everybody,
I am a beginner in programming c++. I have to do a programm that compare a model file to another file (txt files), and if the beginnings of the files are the same, then i have to rename the file compared. This programme works, but i have to compare more than one file with the model file. Therefore i have copied and pasted the following programme several times in the programme:
a=0;<br />
vadves.open("vadves.txt",ios::in);<br />
fstream fichier10;<br />
fichier10.open("ICET0R.WZT.MXS.G0900V00.G2307215",ios::in);<br />
for (i=1;i<=55;i=i+1) {<br />
vadves>>c;<br />
fichier10>>c;<br />
}<br />
while(a==0) {<br />
vadves>>c;<br />
fichier10>>t;<br />
if (c==t&&!fichier10.eof()) {<br />
a=0;
} else { if (vadves.eof()) {
a=2; <br />
} else { a=1;<br />
}<br />
} <br />
<br />
}<br />
vadves.close();<br />
fichier10.close();<br />
if (a==1) {<br />
cout<<"fichier10 is not vadves";<br />
}<br />
if (a==2) {<br />
cout<<"fichier10 is vadves";<br />
rename("ICET0R.WZT.MXS.G0900V00.G2307215", ostr.str().c_str());<br />
}
But i have conclude that once the file model (vadves.txt) has been read i can´t re-read it, even if i close and open the flow vadves.
Therefore, i thought about keeping open the flow vadves and rewinding it. But i don´t know how to use the command rewind, i also heard about fstream command...
Moreover, the file to compar has a name which change every day but always begin with "ICETOR". So is there a command or a programme that could find and associate their name to a value that i could use in my programme? The best command would translate: "for every file beginning whose name begin with ICETOR do ..."
I would be very thankful if somebody could help me
It has been 3 days that i am on this programme... and i am starting to be fed up with it ...
Deep thanks
Guillaume
|
|
|
|
|
What you can do is read the header of the reference file once for all, and then open the other files and compare them against this header reference. You do not need to get rid of your reference stream everytime.
For finding the files, you could use CFileFind::FindFile and CFindFile::FindNextFile.
|
|
|
|
|
Ok, thank you very much.
I am going to try this!
Hope it will work!
|
|
|
|
|
It seems that to use the function CFileFind::FindFile i must have afxwin.h . Unfortunately i don´t have that. Do you know where i can find it?
Moreover concerning the command CFileFind::FindFile , for what i have understood, it could suits my programme to find files. But i don´t understand what kind of type it returns. Could you explain me? (i only have like 30hours of programmation )
Thank you very much!
|
|
|
|
|
|
Don't worry about CFileFind . It's an MFC class which you don't need to be bothered with at the moment. Focus on how to solve the problem first, then you can worry about what tool you want to use. Using simple C++ code will be more than enough.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
garfaoui wrote: ...but i have to compare more than one file with the model file.
So why not just a variable in the call to fichier10.open() rather than a string literal? You could put all of your comparison code in a function, and call that function any number of times using a different filename each time. Make sense?
garfaoui wrote: for (i=1;i<=55;i=i+1) {
vadves>>c;
fichier10>>c;
}
I'm assuming this is for skipping the first 55 bytes of both files. Correct? If so, I believe there is a seekg() function that would be much more elegant.
garfaoui wrote: rename("ICET0R.WZT.MXS.G0900V00.G2307215", ostr.str().c_str());
What is the second argument to rename() ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I didn´t call fichier10.open() simply because i don´t know this function. I am a real beginner!
Concerning the skipping of the 55 first bytes your right. And if i didn´t use the function seekg() it´s again because i didn´t know it exists, so i had to do without it. However, i am not trying to be elegant for now, i am just trying to have programm which works . But next time i have to do that kind of task be sure that i will use seekg()
And finally, the second argument is to put the date at the end of the name of file. It´s related with:
<br />
time_t date_codee;<br />
tm * date;<br />
ostringstream ostr(ostringstream::out);<br />
date_codee = time(NULL);<br />
date = localtime(&date_codee);<br />
ostr << "clippr-" <br />
<< date->tm_mday <br />
<<"-"<br />
<< date->tm_mon + 1 <br />
<<"-"<br />
<< date->tm_year + 1900<br />
<< ".txt";
So now, i have a running programme, but i still have a problem with the name of files which changes every day. I have tryied to get information about CFileFind::FindFile and CFindFile::FindNextFile , but i don´t understand...
Could anyone show me an exemple with wide comments?
Thank you
|
|
|
|
|
garfaoui wrote: I didn´t call fichier10.open()...
Sure you did. Check your original post.
garfaoui wrote: I have tryied to get information about CFileFind::FindFile and CFindFile::FindNextFile, but i don´t understand...
Nor should you, as that just adds unnecessary overhead. Forget MFC was even mentioned. Perhaps you need to look into _findfirst() and _findnext() instead.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
oh yes! i have used it!
ok thank you i will try those command!
Thank you very much!
|
|
|
|
|
Greetings people,
im currently having grief trying to convert a string from type CString to char. here is a sample of the code that im running:
char UserName[25] = '';
wcstombs(UserName, g_xSettings.m_sEmployeeName, g_xSettings.m_sEmployeeName.GetLength()+1);
the problem that im having is that when all is said and done, UserName only hold the first character. For example if g_xSettings.m_sEmployeeName holds "Paul Kiragu" UserName will only have the first character ie "P"
Additional info: im using Microsoft eMbedded C++ 4.0
What am i doing wrong? is there a better way of doing this?
Best regards,
Pete.
|
|
|
|
|
That would be
wcstombs(UserName, g_xSettings.m_sEmployeeName, sizeof( UserName)/sizeof(UserName[0]);
as you need to give the size of your Buffer.
(Ok, the count calculation could technically be omitted, but I include It for completness)
Also, you could add a wcstombs -call with a NULL first parameter, and allocate your string according to the wcstombs return value, which is the size needed.
For your Problem, are you sure about the length? what did strlen( UserName) say?
I could imagine that there is a conversion problem in the debugger visualizing the text in the variable.
But I must admit that I have never used MS Embedded C++.
Failure is not an option - it's built right in.
|
|
|
|
|
Hey dude, thanks a lot! it now works like i want it to.
Only modification that i needed to make was to add 1 to the size of UserName so that it can also take care of the carriage return. and to think that this problem has been eating me alive for two entire days!!!
Once again thanks a million, much appreciated.
Pete.
|
|
|
|
|
in Windows, Control Panel > Regional and Language Options > Advanced > Language for non-Unicode programs
It says that 'It does not affect Unicode programs'
But as to my program, if I choose English as the 'Language for non-Unicode programs', everything is fine. my program can show Chinese or Korean both in menus and dialogs. but if I choose Chinese as the 'Language for non-Unicode programs', My program can't display Korean, if I choose Korean, my program can't display Chinese.
So it seems that my program is affected by this setting.
Maybe my program is not a unicode program? I used UNICODE _UNICODE, and I set wWinMainCRTStartup as the entry point. everything seems working.
So where shall I check? I don't want my program to be affected by this Windows setting.
|
|
|
|
|
If you're using Windows CE up to 5.0 then you've simply run up against the 'can't use more than one east asian language' (Chinese, Japanese, Korean) limitation which is built into CE.
It sounds more like XP in which case your problem would likely be with the default code page as I think that's what's being set in the dialog you mention. Somewhere in your code the default code page is being referenced in a conversion from UNICODE to ANSI characters and setting it to non English is messing up one set of characters or the other. I suspect that when the default code page is English Windows can detect Chinese and Korean characters because they're all 'invalid' in the old ASCII range but when it's Chinese the Korean character values look valid. (Beause of CJK shared characters some of them probably are ). To be safe accross Windows systems that default to all 3 languages you'll need to find the conversion that's failing and preferably avoid it altogether. Remember to separate what you see (glyphs from a font) from the code points that are being represented. I find it helps to try and think in code points but that's really difficult if you're looking at your native language. I18n is hard, good luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hi.
I am trying to create a folder programatically in the all programs of start menu with a dot(.) at the end. But it is ignoring the (.) at the end, and creating the folder without the (.) at the end.
I also observed that the windows itself not allowing to create the folder with (.) at the end.
Pls. help me.
Kishore
|
|
|
|
|
I don't think you can do this, Windows will assumes you have missed off the extension and will simply remove the '.'
Why do yo want to do this ?
|
|
|
|
|
I have a project. The name of the package includes the '.' at the end. For example "A.B.C." . But it is creating the folder "A.B.C" in the all programs of Start menu. The client wants the dot (.) at the end also.
Kishore
|
|
|
|
|
The client may very will want it, but you can't do it unless you have some 'special' non-visible character added to the end of the name.
I don't think you'll be able to do this, also why does the client care if the (.) is there or not ?
Who is going to notice ?
regards,
|
|
|
|
|
The dot is a special character as far as the file system is concerned. It cannot be used in the fashion you desire.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i want to convert WTL coding in to MFC..
is there any way?
please tell...
thanks in advance..
rokini.k
|
|
|
|