|
Hi,
Is there a way by which I can add a ".txt" extension to a filename that I have recieved from a a variable as below..?
const wchar_t* s = xlSheetReadStr(sheet, firstRow+1, 5, NULL);
's' contains a value say "ABC"... I gotta rename it to ABC.txt.... to perform file operations on that file (ABC.txt)..
Thanks,
Faez
|
|
|
|
|
You must create a copy of the string and append the extension. There are several ways to do this:
wchar_t lpszFileName[_MAX_PATH];
wcscpy(lpszFileName, s);
wcscat(lpszFileName, L".txt");
swprintf(lpszFileName, _MAX_PATH, L"%s.txt", s);
std::wstring wstr(s);
wstr += L".txt";
CStringW strFileName;
strFileName.Format(L"%s.txt", s);
This question shows me that you are an absolute beginner to C/C++. This is not a problem. We all were beginners once. But I recommend not to start with a rather complex program using an external library to read Excel files. You should get a good book or tutorial for C++ beginners and work trough it before writing such programs.
|
|
|
|
|
I am really a beginner to C programming Jochen...
I really gotta sitback and build my basics first... Any suggestions for this C beginner..?
BTW... when I tried using the above suggested wchar functions, the code crashes and I get an error saying "An unhandled Win32 exception occured "......
|
|
|
|
|
There a many books and online tutorials, but I don't know which are best for beginners. See here [^] for some books and here [^] for an online tutorial (also available as PDF). If English is not your first language, you may look for tutorials in your native language. Just search for "C++ beginners tutorial".
You should pick only one of the functions (the swprintf example requires the wchar_t lpszFileName variable). A possible error may be a buffer overflow when your file name is longer than _MAX_PATH. To avoid buffer size problems, use std::string or CString .
|
|
|
|
|
I was unable to use any of the above functionality because I didn't have the <wcstr.h> header file in my MinGW.
What i did was, I copied the the acquired const string value into a file and then read it again by storing it in a new variable as below
char* dclColEle[10];
After getting such four column values, I am not able to individually access the dclColEle[0], dclColEle[1], dclColEle[3] values... i get junk or no values when i try to access them..
|
|
|
|
|
Faez Shingeri wrote: I was unable to use any of the above functionality because I didn't have the <wcstr.h> header file in my MinGW.
When using MinGW, use strcpy() and strcat() , or snprintf() . Use PATH_MAX instead of _MAX_PATH . Required include files are stdio.h, stdlib.h, and string.h.
Faez Shingeri wrote: char* dclColEle[10];
This creates an array with 10 elements where each element is a pointer to char. I assume, that this is definitely not what you want.
|
|
|
|
|
|
Your questions are no longer related to the initial topic. I suggest you should create a new topic here in the C/C++ forum or in the Q&A section.
When doing so, much more people will read it and may answer.
|
|
|
|
|
Hello Friends
I am creating an application in which I have to read XML File. That XML file is having different types of nodes and Data stored in it.
I an creating a separate class for each node to read its data and subnodes.
I want a component based structure for class tht I dont need to initialize each node class object everytime.It must be Inherited from one main XML class and all other component class should implement their virtual fn.
Any Structure Idea for this Design.
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
try factory pattern and it's variant
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi,
I have a twofolded question
If I want text on a new line when using Streamin Callback Function for a Rich Edit control I insert a carriage return line feed at the end of the buffer correct ?
and if yes I have the following code which doesn't seem to work
LPBYTE holdptr1, pbBuff;
CString buffer;
strcpy((char *)pbBuff," ");
holdptr1 = pbBuff + 2;
memcpy(holdptr1,buffer.GetBuffer(121),121);
holdptr1 = holdptr1 + 121;
memcpy(holdptr1,"\r\n",2);
*pcb = 125;
|
|
|
|
|
You've declared these pointers, but you haven't allocated any memory for them to point to:
LPBYTE holdptr1, pbBuff;
Another probable error is that you are changing what holdptr1 is pointing to by adding to it:
holdptr1 = holdptr1 + 121;
After seeing this post and some of your previous posts, I can say that you need to study how pointers work. You'll never be able to write code in C/C++ until you fully understand them.
You should find a tutorial or a book that you like, and study it.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
In addition to the other Richard's comments, you should not use fixed value offsets in this way; it will lead to pain and tears very quickly.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
We issue Software licences on the basis of the Hardware Serial Number and Manufacturers Data stored in the Hard Disk Firmware of the primary disk that our Sotfware is stored on. My Step grandson was interested in learning the operational aspects of the App, so I tried to install it on his notepad. The Licence Aspect Failed, because our Standard Detection Software could not find a Physical Device for Drive 'C:\'
I am not aware of any licensing issues Microsoft had when releasing this version of Windows7 Does anyone know how to obtain similar Machine Identification Data on this type of hardware, that can be used for licencing purposes.
Regards,
Bram van Kampen
|
|
|
|
|
WMI is frequently used for this purpose.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Well,
Those Notepads have No HardDrive, and hence No HardDrive Serial Number, so the Obvious Alternative is the CPU Serial Number.
Richard Andrew x64 wrote: WMI is frequently used for this purpose.
Well, Looked at that. WMI (as far as I can see, gives the Processor Make, Type, etc,etc,etc..., except The CPU Manufacturers Serial Number.
Thanks,
Bram van Kampen
|
|
|
|
|
I have dialog base MFC application
Dialog box contains only one control(radio button)
to change the text color of radio button i use oncltcolor(WM_CTLCOLOR)
BUT it's now working
i am using xp theme
is there any solution
|
|
|
|
|
MKC002 wrote: BUT it's now working
I assume that should read not working, in which case you need to give more detail, including a snippet of your code showing where it is going wrong.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I have dialog base application, dialog box contains one radio button. to set the text color of radio button
HBRUSH CtestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
......
// TODO: Change any attributes of the DC here
if (pWnd->GetDlgCtrlID() == IDC_RADIO1)
{
pDC->SetTextColor (RGB(128,0,0)); // blue
}
.....
}
This code works fine and radio button color gets changed
but if i use xp theme in this project then text color of radio button does not set.
To set xp theme, i add one custom resource which contains
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
processorArchitecture="x86"
version="5.1.0.0"
type="win32"
name="testdlg.exe"/>
<description>testdlg</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86"/>
</dependentAssembly>
</dependency>
</assembly>
|
|
|
|
|
I think you may need some extra code in your override, as described here[^].
BTW please use <pre> tags round your code snippets to make them more readable.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I tried to use given example but the text color for radio button does not set. The background color of radio button is set.
I noticed if i create a dialog box application in visual studio 2008,add one radio button and set its text color in OnCtlColor then the text color does not set.
modified 3-Feb-12 1:38am.
|
|
|
|
|
Unfortunately I do not have an MFC capable version of VS so I cannot test it myself.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Use a sentence, positive and negative output,
For example :
1 -1 2 -2 3 -3 4 -4 5 -5 ...... 1000 -1000
Can use a formal parameters, Can't use loop
Example, pictures address: http://www.hotimg.com/direct/qECUqQ9.jpg
modified 1-Feb-12 11:01am.
|
|
|
|
|
Try rephrasing this... don't understand what you're trying to do. Also, is this your homework? Sounds like it...
|
|
|
|
|
What?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|