|
|
Hi All,
I have a VC++ application its a bit big application having more than 10 ATL
components. The application is client/server architecture with
multi-threading. The server does the data trasnfer from one database to
another using ODBC/OLEDB.
If at all I want to change the technology from VC++, is it advisable to
migrate it to .NET? Can any one comment on the migration plan from vc++ to
.NET?
--
Thanks
ChitraCK
|
|
|
|
|
hi everybody,
i have an issue regarding running dos comds from vc ++ program . If we want to run user interactive command from the vc++ how can we do it.
to amplify the issue , there is a command which says gcc -v, now the output of this command is a one time single line output, which requires no user input. Now i am able to run such one line commands through vc++ GUI, however, I am having problem in running commands which require user input, say if there is a command which says gpg --gen-key , now this command when run in command prompt prompts user for various inputs like choose encryption algo, give user name , email id, etc..... .Now How can a GUI be build to run such commands which only get completed after taking various inputs from user ...If you feel i need to study more kindly show me the path to study something in the right direction...the field and subject is so vast otherwise..
can any one please guide me if there is another approach or a better way to do .......in vc++ using MFC .
thanks to all who took pain to read the query atleast....
vineet madan
-- modified at 9:20 Thursday 3rd August, 2006
Thanks to everybody who even thought of helping me. regards--vineet
|
|
|
|
|
Are you wanting to pass data to your console application from your GUI application? If so, see here and here.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Dear david,
thanks for the reply , i am going through the tuorial u have mentioned. . I must thank you once again for prompt reply. I will look fwd for more guidance from you.
regards --vineet
Thanks to everybody who even thought of helping me. regards--vineet
|
|
|
|
|
Hi,
If I can declare a function as
void Show(int i = 1729,double d);
But I can't call this function by passing only 2nd argument then what is the use of that function? OR How to use this function (to pass only 2nd argument)?
ex.
void Show(int i, double d = 3.14);
void Show(int i = 1729,double d);
void Show(int i, double d)
{
printf("\n\t %d %0.2lf",i,d);
}
main()
{
Show(); // Output 1729 3.14
Show(12); // Output 12 3.14
Show(45,5.6); // Output 45 5.60
Show(23.9); // Output 23 3.14 ....... But can I get output as 1729 23.9 ?
}
Thanks & Best Regards,
Aniket Salunkhe
|
|
|
|
|
default arguments only starts at the end of the parameters list...
|
|
|
|
|
toxcct wrote: default arguments only starts at the end of the parameters list...
I know that...but see the program given by me ... it doesn't show error
-- modified at 9:08 Thursday 3rd August, 2006
|
|
|
|
|
Only the last arguments in the arguments list can assume a default value.
"void Show(int i = 1729,double d);" is not correct
If you need to pass int or double you can use polymorphism ...
void Show( int i= 1729 );
void Show( double d=3.14);
void Show(int i, double d);
|
|
|
|
|
Nyarlatotep wrote: If you need to pass int or double you can use polymorphism ...
void Show( int i= 1729 );
void Show( double d=3.14);
void Show(int i, double d);
This is function overloading ... not polymorphism.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
also called "function polymorphism"
|
|
|
|
|
Polymorphism is generally used with reference to classes or objects, and it deals with method OVERRIDING, not overloading.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Arguments with default values must come at the end of the argument list. C++ does not provide a syntax for specifying missing arguments.
Another thing you might be seeing, since you are using numeric arguments, is that the compiler will automatically convert numeric constants to the correct type.
The best way to do this would be:
void Show(double d,int i = 1729)
{
printf("\n\t%d %lf",i,d);
}
main()
{
Show();
Show(12);
Show(5.6,45);
Show(23.9);
}
Software Zen: delete this;
|
|
|
|
|
You cannot pass just the second parameter. If you change the declaration so that the default parameters are the last arguments to your function, you can pass the first arguments and skip the default ones (if desired), but you cannot do it the way you are trying to.
Also, you cannot create the same function with the same arguments and different default parameters.
Aniket Salunkhe wrote: void Show(int i, double d = 3.14);
void Show(int i = 1729,double d);
void Show(int i, double d)
Declaring all 3 of those will give you a compiler error.
void Show(double d, int i = 1729);
Show(3.14);
Show(3.14, 2000);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Neither C nor C++ support "named parameters." See here for more.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: named parameters
One of the the (all too few) cool things about the Ada programming language. Named parameters made for more readable and self-documenting code.
Software Zen: delete this;
|
|
|
|
|
|
I've a weird problem making me crazy !!!
I've to read a sequence of dates from a text file and convert these dates into time_t.
I DON't want to take into account timezones and daylight savings, so the input date must be converted into the exact output date.
So, i've avoided mktime() to convert from tm (filled up with string dates from source) to time_t.
The next solution i've used was to convert a SYSTEMTIME to a time_t with these functions (based on similar functions, UnixTimeToSystemTime(), described in MSDN):
void FileTimeToUnixTime(LPFILETIME pft, time_t *t)
{
LONGLONG ll;
ll = pft->dwHighDateTime;
ll <<= 32;
ll |= pft->dwLowDateTime;
ll = ll - 116444736000000000;
*t = ll / 10000000;
}
void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t)
{
FILETIME ft;
SystemTimeToFileTime(pst, &ft);
FileTimeToUnixTime(&ft, t);
}
because I was sure that SystemTimeToFileTime() only converts to SYSTEMTIME format to FILETIME format without any other considerations like timezone or daylight saving.
In my PC these work well. When I've run the code in another PC, the resulting date is 1 hour back.
(it's very strange too, because that PC has the same date settings of mine).
I can't achive the result to obatin a time_t that reflect the same source date, without variations caused by currently timezone and daylight saving settings.
-- modified at 9:12 Thursday 3rd August, 2006
|
|
|
|
|
Nyarlatotep wrote: I've to read a sequence of dates from a text file...
What do these dates look like?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Input file is a CSV file. Dates are in dd/mm/yyyy format and I've to convert those dates into time_t without time zone o daylight saving affection ...
|
|
|
|
|
If you are reading the dates in as dd/mm/yyyy, then you can separate the three components like:
char dateToday[] = "04/08/2006";
char *pDay = strtok(dateToday, "/"),
*pMonth = strtok(NULL, "/"),
*pYear = strtok(NULL, "/"); Now you can convert those to numeric values using atoi() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
My problem is not to parse the input string date.
I parse the input date and input time and put each value into a tm struct (day, month, year, hour, minutes, seconds) and I'have used mktime() function to convert from the tm struct to time_t value.
BUT
mktime() takes into account time zone and daylight saving so, for example, if input date into the tm struct is 01/06/2006 15:00:00 (first June), the time_t date obtained from mktime() is 01/06/2006 17:00:00 (I am in GMT +1 and day light saving is in effect adding an extra hour).
Instead I want to convert the parsed date into time_t without take into account time zones and day light saving, obtaining the the same date as the input, in every time zone the program runs.
To avoid this 'problem' I've tried to use a function (see inital post) that use SystemTimeToFileTime internally, because I thought that SystemTimeToFileTime only converts from SYSTEMTIME struct to FILETIME struct without taking into account time zones and day light saving. But I was wrong, I suppose.
-- modified at 10:23 Friday 4th August, 2006
|
|
|
|
|
Nyarlatotep wrote: My problem is not to parse the input string date.
My bad. I just assumed you had the math worked out, but was having difficulty with the parsing.
Nyarlatotep wrote: ...mktime() takes into account time zone and daylight saving so...
So what is the value of tm_isdst prior to calling mktime() ?
Nyarlatotep wrote: ...the time_t date obtained from mktime() is 01/06/2006 17:00:00
What are you using to convert the time_t value to a string?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I've set tm_isdst to 0.
However to convert the string into time_t I've used these functions (insted of mktime):
void FileTimeToUnixTime(LPFILETIME pft, time_t *t)
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = pft->dwHighDateTime;
ll <<= 32;
ll |= pft->dwLowDateTime;
ll = ll - 116444736000000000;
*t = ll / 10000000;
}
void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t)
{
FILETIME ft;
SystemTimeToFileTime(pst, &ft);
FileTimeToUnixTime(&ft, t);
}
the datetime string is parsed and a SYSTEMTIME struct is filled. Then SystemTimeToUnixTime() is used to convert from SYSTEMTIME to time_t.
---------------------------------------------------
To revert time_t to a string I've used these functions :
void UnixTimeToFileTime(time_t t, LPFILETIME pft)
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
}
void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
{
FILETIME ft;
UnixTimeToFileTime(t, &ft);
FileTimeToSystemTime(&ft, pst);
}
time_t is converted to a SYSTEMTIME by UnixTimeToSystemTime(). Then I've build a datetime string using SYSTEMTIME members.
These functions use internally FileTimeToSystemTime() and SystemTimeToFileTime() and no other OS functions.
I've thought that these two functions only convert SYSTEMTIME to FILETIME and vice versa without taking into account time zone and day light saving ...
|
|
|
|
|
I'm not sure what effect all of those other functions have on the date value, but I tried the following and got the correct output both times regardless of the value of tm_isdst :
struct tm now;
now.tm_sec = 0;
now.tm_min = 0;
now.tm_hour = 15;
now.tm_mday = 1;
now.tm_mon = 5;
now.tm_year = 106;
now.tm_wday = 5;
now.tm_isdst = 1;
printf("%s", asctime(&now));
time_t t2 = mktime(&now);
printf("%s", ctime(&t2)); I guess I'm just not understanding your problem well enough.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|