|
Hi Guys, I am using CDateTimeCtrl in my project.I dont know how to get Date, Month and Year Separatly.
If you Know explain me with simple code
Thanks in Advance
|
|
|
|
|
How about reading the documentation in MSDN and letting us know what you did not understand after seeing the member functions of this class to get the date, month and year separately?
Read GetTime function and refer the SYSTEMTIME structure.
I am a HUMAN. I have that keyword (??? too much) in my name........
_AnsHUMAN_b>
|
|
|
|
|
|
Use the method "GetTime" and then Format the CTime-object.
Example to get the month:
CTime timeTime;
theDateTimeCtrl.GetTime(timeTime);
CString strMonth(timeTime.Format(_T("%m"));
Now the Month is in the string.
Look in the documentation of strftime to get the formatting codes.
|
|
|
|
|
hi,i'm currently doing a project using a software,Waspmote. I have some problems with my codings,it gave me 2 errors when i tried correcting it,
In function 'void loop()':
error: expected initializer before 'uint8_t'
In function 'void loop()':
error: a function-definition is not allowed here before '{' token
could anyone kindly help me take a look at the codings and suggest ways for me to improve on it.The code is as shown below:
int n=0;
void setup(){
// setup for Serial port over USB
USB.begin();
USB.println("USB port started...");
USB.close();
// Powering BT
BT.ON();
// Init
if(!BT.init()) USB.println("Init OK");
}
void loop()
{
// Searching for devices
if(!BT.scanNetwork()) USB.println("Scan OK");
else USB.println("Scan failed");
// Printing the devices that have been found
for(int l=0;l<BT.devices_found;l++)
{
n=0;
USB.print("---- DEVICE ");
USB.print(l,DEC);
USB.print(" ---- ");
USB.print("MAC: ");
for(int m=0;m<12;m++)
{
USB.print(BT.discovered_devices[l].mac_address[m],BYTE);
}
USB.print(" -- NAME: ");
while(BT.discovered_devices[l].name[n]!='\0')
{
USB.print(BT.discovered_devices[l].name[n],BYTE);
n++;
}
n=0;
USB.print(" -- CoD: ");
while(BT.discovered_devices[l].CoD[n]!='\0')
{
USB.print(BT.discovered_devices[l].CoD[n],BYTE);
n++;
}
USB.println("");
delay(2000);
}
// Creating a connection to a device
if(!BT.createConnection("0017E5F1CF74","02"))
{
USB.println("");
USB.print("--- CONNECTION -- MTU: ");
USB.print(BT.connection_mtu[0],BYTE);
USB.print(BT.connection_mtu[1],BYTE);
USB.println(BT.connection_mtu[2],BYTE);
}
else USB.println("Connection failed");
delay(1000);
void printData(char* data )
{
uint8_t uart=0;
printString(data,uart);
printByte('\r',uart);
printByte('\n',uart);
}
delay(2000);
return ;
}
|
|
|
|
|
Check where you put your braces { }. It looks to me like your "printData()" function is INSIDE "loop()". Indenting your code neatly NEVER hurts and often (in cases like this) helps you see what you've written.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
thanks for the reply.I tried removing the brackets but it still doesn't work,if possible may i just trouble you to help me correct the codings because i'm rather new in programming.
|
|
|
|
|
I didn't say remove the braces. You need to get them matching correctly, like this:
func1() {
...
...
}
func2() {
...
...
}
What you had is more like
func1() {
...
...
func2() {
...
...
}
}
See how the indentation makes it easy to spot the problem?
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
After looking through the codes and compiling, I still get an error:
In function 'void loop()':
error: a function-definition is not allowed here before '{' token
int n=0;
void setup()
{
USB.begin();
USB.println("USB port started...");
USB.close();
BT.ON();
if(!BT.init()) USB.println("Init OK");
}
void loop()
{
if(!BT.scanNetwork()) USB.println("Scan OK");
else USB.println("Scan failed");
for(int l=0;l<BT.devices_found;l++)
{
n=0;
USB.print("---- DEVICE ");
USB.print(l,DEC);
USB.print(" ---- ");
USB.print("MAC: ");
for(int m=0;m<12;m++)
{
USB.print(BT.discovered_devices[l].mac_address[m],BYTE);
}
USB.print(" -- NAME: ");
while(BT.discovered_devices[l].name[n]!='\0')
{
USB.print(BT.discovered_devices[l].name[n],BYTE);
n++;
}
n=0;
USB.print(" -- CoD: ");
while(BT.discovered_devices[l].CoD[n]!='\0')
{
USB.print(BT.discovered_devices[l].CoD[n],BYTE);
n++;
}
USB.println("");
delay(2000);
}
if(!BT.createConnection("0017E5F1CF74","02"))
{
USB.println("");
USB.print("--- CONNECTION -- MTU: ");
USB.print(BT.connection_mtu[0],BYTE);
USB.print(BT.connection_mtu[1],BYTE);
USB.println(BT.connection_mtu[2],BYTE);
}
else USB.println("Connection failed");
delay(1000);
void printData(char* data )
{
uint8_t uart=0;
printString(data,uart);
printByte('\r',uart);
printByte('\n',uart);
}
delay(2000);
return ;
}
|
|
|
|
|
I just pasted that code into my syntax-highlighting editor, and it tells me that the very last close brace matches the one immediately after void loop() . So void printData() is still "inside" void loop() . Again, the indenting should give you a clue - void printData() isn't in column 1 like the other functions are.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I taken
void printData out from the
loop .There are no more errors,but when i upload the codings to the waspmote IDE, it doesn't send out the text to external devices through the bluetooth device.Do you have any recommendations for me to modify my existing source code?
|
|
|
|
|
dusk85 wrote: Do you have any recommendations for me to modify my existing source code?
Quote Selected Text
The short answer is no. I am happy to help with getting your code to compile, but I'm not going into your bluetooth issues. I suggest you try a forum for bluetooth or waspmote (whatever that is).
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
You really should never present unformatted code. Using PRE tags would preserve indentation and make things readable, and maybe the mistake obvious.
|
|
|
|
|
Does anyone know if I can make the SDK 7.1 directories the default instead of using the SDK 7.0!
I know that you can configure them on each solution, but it is very boring to set them on each solution.
Or should I copy and replace files of 7.0A with 7.1.
(Might even free up some disk space in the process)
|
|
|
|
|
Does anyone know if the new mysql libraries can be called from the old old vc6 (on windows xp)?
thanks!
|
|
|
|
|
Yes, they perfectly work togheter ... swend me an email, and I'll send to you a test application ...
|
|
|
|
|
If I assign a string to a variable.
char* t = "Hello World!";
Doesn't this string get a fixed array with a null terminator at the end?
|
|
|
|
|
Yes. Take a look at it in the debugger if you are not sure.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
wcscat_s keeps throwing an error that the string isn't null terminated! :S
|
|
|
|
|
Are you sure it doesn't throw an exception, because the memory provided in strDestination argument is read-only?
|
|
|
|
|
Fareed Rizkalla wrote: wcscat_s keeps throwing an error that the string isn't null terminated!
Yes, I'm not surprised since you are sending it a char* (i.e. ASCII string) but wcscat_s() expects Unicode.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
No. It assigns a pointer to a fixed null-terinated string, there is a slight difference between arrays and pointers. A writable block of memory is not allocated and you should get a compiler warning because of the unsafe conversion... change the code to:
const char* t = "Hello World!";
Hope this helps
|
|
|
|
|
Moak wrote: a pointer to a fixed null-terinated string,
Which is simply an array of characters.
Moak wrote: there is a slight difference between arrays and pointers.
I would say there is a huge difference.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
every literal string gets a NULL appended automatically by the compiler.
However there are 8-bit and 16-bit characters and strings, and you can't just mix them.
If you use wcscat_s, you want wide char strings, the example in MSDN is:
wchar_t wszStr[] = L"1a1g";
|
|
|
|
|
Hello. I created a new icon in the resource view called "IDI_OBJECT_GLOBAL_VAR". In my "View" cpp, I added the icon to my HICON ( along with a bunch of other icons that work) using the following:
hIcon[ICON_INDEX_OBJ_GLOBAL_VAR] = AfxGetApp()->LoadIcon(IDI_OBJECT_GLOBAL_VAR);
This is then added to a tree list :
for( GUShort index = 0;
index < ICON_INDEX_MAXIMUM;
index++ )
{
m_TreeImageList.Add( hIcon[ index ] );
}
GetTreeCtrl().SetImageList( &m_TreeImageList, TVSIL_NORMAL );
When I go to insert an item with the icon, I use the following:
hNewItem = GetTreeCtrl().InsertItem( label,
ICON_INDEX_OBJ_GLOBAL_VAR,
ICON_INDEX_OBJ_GLOBAL_VAR,
parentTreeItem,
hInsertAfter );
The item itself is placed in the tree, but the icon NEVER displays. It's just blank. Any help on this would be appreciated. Thanks!
|
|
|
|