|
Can you not search this code yourself? Database_close() is called right before main() returns.
In the future, please post only relevant code snippets.
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
omg,sry about that badd miss,and thanks anyway!
|
|
|
|
|
Hi,
Is there any way to convert WMI Win32_OperatingSystem InstallDate to mm/dd/yyyy format in C++. I have seen there is a class defined in C# for the same. But I didn't find anything in C++.
When I run WMI query "Select InstallDate from Win32_Operating system", I get : 20120714160600.000000+330 as the result.
I want to convert this to some readable format e:g: dd/mm/yyyy format with time also.
Anybody have any idea about this.?
Regards,
Mbatra
|
|
|
|
|
|
I am trying to enable an application for unicode.
//char c_buffer[ARRAY];
TCHAR c_buffer[ARRAY];
above are the changes I made into code.
Which breaks at this code in the .cpp file
sprintf(c_buffer, "%d", pb->i_id);
abc.cpp: error C2664: 'sprintf': cannot convert parameter 1 from 'TCHAR *[1024]' to 'char *'
Why so ?
I have added TCHAR.h and strsafe.h
|
|
|
|
|
Use wsprintf -
wsprintf(c_buffer, _T("%d"), pb->i_id);
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
Worked ! great... thanks
|
|
|
|
|
Hello superman...just trying my luck by asking this to you...
problem piece of code - if(Function(parm1, parm2, parm3)==0){
error - cannot convert parameter 3 from 'char [1024]' to 'wchar_t *'
Function is expecting wchar_t but its getting char[1024] from some where.
I changed the function signature to accept wchar_t type in header file.
objective is to make the whole code UNICODE enabled. I have added all the tchar.h, wchar.h fiels
param 3 has been defined (modified) as wchar_t in all the connected files too.
I cant debug yet. Pls help how can i get rid of this error.
I am working in vs2010.I counter checked it about five times and gave the search in solution to find if parm3 is still 'char' somewhere else.
I am seriously doubting typecasting the wchar_t parm3[] before passing it function i think.
I went to function declaration and changed it to char* to wchar_t* too. I doubt that might not be straight forward. there should be some changes.
|
|
|
|
|
To support UNICODE, you need to use wchar_t instead of char .
You also need to use the string functions that work on wchar_t like wcslen , wcscat etc.
While defining string literals use the L prefix - L"Hello World"
If you have a string that is already encoded as ASCII, you need to convert it to UNICODE.
Simply typecasting will not work.
You can use the MultiByteToWideChar[^] API to do the conversion.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
|
However, the swprintf function, which is a VC++ library function is the correct one to use.
The wsprintf function is part of some windows API, and does not support all the formatting options. For example wsprintf does not support the "*" width specification.
Thanks !
|
|
|
|
|
If you are using TCHAR to define your data then you must use the routines with the _st prefix as described in http://msdn.microsoft.com/en-us/library/ybk95axf.aspx[^]/ This allows the compiler to generate code for ASCII or Unicode depending on your project settings. If your program is only ever going to handle Unicode character data then you should use WCHAR and the PW prefixed pointers.
|
|
|
|
|
Quote: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char **’
|
|
|
|
|
|
ok ,thnk u but for the parameter char ** what format we should declared to print?
|
|
|
|
|
Read the documentation I gave you the link for; it describes all the available format types and what parameters they require. There is no format type that handles char** , for a very good reason.
|
|
|
|
|
The format %s is used to output a null terminated string.
The variable it expects is a char* .
I can think of 2 possibilities.
Since you haven't posted any relevant code, I'm only guessing here.
First guess is that you're trying to print a string and are using an extra & character -
char string[20];
printf("%s", &string);
Second guess is that you've received a char** as a function argument and trying to print it.
void fun(char** arg)
{
printf("%s", *arg);
}
It would be best if you can post the relevant code.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
What are the basic features provide by CCmdTarget??
|
|
|
|
|
Message mapping and COM support.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
|
|
<blockquote class="quote"><div class="op">Quote:</div>#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include "Utility.c"
#include<dirent.h>
float* random1(int SizeOfData);
int main(void)
{
int i,j;
int SizeOfData=63530;
float* squaring;
float total_sum,summation_noise;
float* random_seq=(float *)malloc(SizeOfData* sizeof(float ));
random_seq=random1(SizeOfData);
for(i=0;i<SizeOfData;i++)
{
printf("\t%f\n",random_seq[i]);
}
return 0;
}
</blockquote>
// utility.c
<blockquote class="quote"><div class="op">Quote:</div>float* random1(int SizeOfData)
{
srand(12345);
int i,j;
float sum=0.0;
float a=0.2;
float summation_noise=0.0;
float *y;
y=(float *)malloc(SizeOfData* sizeof(float ));
for(i=0;i<SizeOfData;i++)
{
float f= ((float)rand()/(float)(RAND_MAX))*a;
y[i]=f;
}
return y;
</blockquote>
while running expected output has to be random float number from 0-63530
but it is displaying only one number .
|
|
|
|
|
Quote: #include "Utility.c"
What's its purpose (usually you include just header files)?
Your program (without such line) runs producing the expected output.
Please note:
Quote: float* random_seq=(float *)malloc(SizeOfData* sizeof(float ));
is useless, since memory is allocated inside the random1 function.
- You never free the allocated memory (you have to ).
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
utility.c is the program file where the function is declared from there I was aiming to call to main.c that y I include it.
|
|
|
|
|
maibam debina wrote: utility.c is the program file where the function is declared What function? You know, functon declarations should be inside header files and you should include just header files (as rule of thumb for beginners, at least).
Quote: rom there I was aiming to call to main.c that y I include it You cannot call a file (main.c is a file).
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|