|
<br />
#include"iostream.h"<br />
#include"string.h"<br />
#include"iomanip.h"<br />
<br />
char *ID;<br />
ID = new char[size];<br />
char Buffer[20] , temp = 'c';<br />
int abc = 10;<br />
itoa( abc , Buffer , 10 );<br />
ID = new char[strlen(Buffer) + 1];<br />
ID[0] = 'c';strcat(ID , Buffer);<br />
this is my code
by the way #include "stdafx.h" dosnt seems to work i am using visual c++
also the other 2 include in your previosu example cant be seen >.<
|
|
|
|
|
#include "stdafx.h"
#include iostream use ">"
#include tchar.h
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char *ID;
ID = new char[50];
char Buffer[20] , temp = 'c';
int abc = 10;
itoa( abc , Buffer , 10 );
ID = new char[strlen(Buffer) + 1];
ID[0] = 'c';strcat(ID , Buffer);
cout<<"Value="<<buffer<<"\n";
return="" 0;
}
=""
<font="" size="2" color="#99ff66">
whitesky
|
|
|
|
|
|
char *ID;
char Buffer[20];
int abc = 10;
itoa( abc , Buffer , 10 );
ID = new char[strlen(Buffer) + 2];
ID=Buffer;
strcat(ID ,"c");
cout<<"Value="<<id<<"\n";
<font="" size="2" color="#99ff66">
whitesky
|
|
|
|
|
i hope i am not troubleing u >.<
now the output is 10c i am trying to get c10 >.<
i already tried this:
ID="c";
strcat(ID ,Buffer);
got error...
|
|
|
|
|
well ok i mistake i think your problem is itoa so its easy use
<br />
<br />
#include "stdafx.h"<br />
#include windows.h<br />
#include iostream<br />
#include tchar.h<br />
using namespace std;<br />
<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
char *ID;<br />
char temp = 'c';<br />
int abc = 1240;<br />
ID = new char[sizeof(ID)];<br />
<br />
wsprintf(ID,"%c%d",temp,abc);<br />
<br />
cout<<"Value="<<ID<<"\n";<br />
return 0;<br />
}<br />
<br />
<br />
whitesky
|
|
|
|
|
i dont quite understand
my objective is actually to store the lettle "C" and an int into a string so the coutcome will become like this C10 or C203
curretly the include i am using are
#include"iostream.h"
#include"string.h"
#include"iomanip.h"
i not allowed to use namespace std haha >.<
so can anyone try help me ?
|
|
|
|
|
Instead of strcat() in my first answer , use the memcpy().
I tested this code and it's working:
char *ID , Buffer[20];
int abc = 10;
int nLen = 0;
_itoa( abc , Buffer , 10 );
nLen = strlen(Buffer);
ID = new char[nLen + 2];
ID[0] = 'c';
memcpy(ID + 1 , Buffer , strlen(Buffer));
ID[nLen + 1] = '\0';
Eli
|
|
|
|
|
i tryed it with include"iostream" it works but it dosnt work in include"iostream.h"
do i have to include nay additional stuff??
by the way i say thx to all those who have helped me in advance =)
really help a lot
|
|
|
|
|
this code==> _itoa( abc , Buffer , 10 );
i tryed it with include"iostream" it works but it dosnt work in include"iostream.h"
do i have to include nay additional stuff??
by the way i say thx to all those who have helped me in advance =)
really help a lot
|
|
|
|
|
I think your problem is solve.
Can you explain what do you need exactly,please?
whitesky
|
|
|
|
|
yes my problme is solve but i cant use this function -->_itoa( abc , Buffer , 10 );
the itoa part dosnt work unless i use include"iostream" but i am using include"iostream.h"
so i am just asking there is anything else to include so that i may use include"iostream.h"
together with the itoa function
|
|
|
|
|
neodeaths wrote: so i am just asking there is anything else to include so that i may use include"iostream.h"
together with the itoa function
Yes, the prototype of the _itoa function is present in the stdlib.h header file
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
I rated you 1 -- it would be quicker for you to check MSDN library than to ask on CodeProject what itoa does.
|
|
|
|
|
>.< when i thinking i forgot got the library >.<
=P
any way thx for all the help u guys gav me
|
|
|
|
|
want to check if a folder exists in a computer or not. for example if the path is
"c:\DK\Index " i want to check if the folders DK and Index already exists in c
drive. if it doesn't exist,then these folders should be created. if the folders already exists nothing needs to be done. i want to check this when the dialog box is initialised. can anyone give the code to do this.
Thank You
|
|
|
|
|
|
Hi ,
Try this :
CFileFind finder;
CString szPath , szCMD;
szPath = "c:\DK\Index";
if(!finder.FindFile(szPath))
{
szCMD = "mkdir ";
szCMD += szPath;
system((LPCTSTR)szCMD);
}
With best regards,
Eli
|
|
|
|
|
Thank you Mr. eli the code given by you is working fine. Thanks to all of you who have responded
|
|
|
|
|
<br />
WIN32_FIND_DATA m_data;<br />
HANDLE hFile;<br />
hFile=FindFirstFile("c:\\test",&m_data);<br />
if(hFile==INVALID_HANDLE_VALUE) <br />
MessageBox("Not Found");<br />
else<br />
{<br />
MessageBox("ok");<br />
FindClose(hFile);<br />
}<br />
<br />
whitesky
|
|
|
|
|
Another way to do it: Using CFileStatus from MFC..
CString folderPath = _T("C:\\DK\\Index");
CFileStatus status;
if(!CFile::GetStatus( folderPath, status ) )
{
AfxMessageBox(_T("Directory does not exist.(\"") + folderPath + _T("\")\n"),
MB_OK|MB_ICONINFORMATION);
...
}
The use of _access (posted by Chris Losinger) may be more suitable for your needs.
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
Hi !!!
If you want xou can use the InetSTL from STLSoft library. There is a function that can check wheather the directory exists or not.
You can find it here: http://www.stlsoft.org
I hope, I helped you.
By.
-:KNOX:-
|
|
|
|
|
I will really, really appreciate comments about a discussion in another web site. The reason I am asking here is because I feel unable to get an objective answer in the other site.
See the CodeGuru Forums - struct vs class? thread. I posted a message saying that the question did not ask about C structures. I will appreciate knowing if my comment is valid.
-- modified at 23:48 Saturday 20th May, 2006
|
|
|
|
|
Sam Hobbs wrote: The reason I am asking here is because I feel unable to get an objective answer in the other site.
I read through the posts but I'm not sure what your question was. You stated a "matter of factly" thing. Case closed.
The other participants seem preoccupied with quoting their textbooks. The question was too vague to begin with and warrants the issuer open a few books him/her self.
|
|
|
|
|
Thank you. Yes, I was vague intentionally. I wanted to be fair and not influence people's reaction.
|
|
|
|