Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

DengJW

@DengJW
About
Posts
80
Topics
42
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Access Active Directory to Control PC User Logon?
    D DengJW

    Hi everybody, Currently i am thinking how to program a PC Booking/Reservation System for an office of 100 PCs where user login is controled by Windows Active Directory. I have little idea about AD login control, anybody can tell me where to start? Thanks JW DJ

    C / C++ / MFC windows-admin tutorial question

  • How to code to stop a printer driver?
    D DengJW

    Hi, ALl I am having a problem with a Printer running on Window XP... The computer would run into :((BLUE SCREEN during shutting down if the Printer had been turned before shutdown? One solution is to uload or stop the printer driver before shutdown. My questions are: 1) how to write a program that can stop or unload the printer driver? 2) how to let XP automatically unload the driver instead of manually just before shutdown? Your help and contribution appreciated! JW DJ

    C / C++ / MFC help tutorial question

  • will this be compiler(M$ cl) bug or Memory leakage?
    D DengJW

    Microsoft Compiler Ver 12.00.8168 from VC++ 6. I could not reproduce the problem either. So I guess the chance would be high that I accidently uncommented both ans = (f()) >= 0 ? (f()) : -(f()); and ans = unsafe(f());. So far, I could not think out other reasons. DJ

    C / C++ / MFC help performance question

  • will this be compiler(M$ cl) bug or Memory leakage?
    D DengJW

    #include
    #define unsafe(i) \
    ( (i) >= 0 ? (i) : -(i) )

    inline
    int safe(int i)
    {
    return i >= 0 ? i : -i;
    }
    int f() {cout << "Called f()!" << endl; return 0;};
    void userCode(int x)
    {
    int ans;
    ans = unsafe(x++); // Error! x is incremented twice
    cout << "[1] "<< x << endl;
    // ans = (f()) >= 0 ? (f()) : -(f());
    ans = unsafe(f()); // Danger! f() is called twice
    cout << "[2] "<< x << endl;

    ans = safe(x++); // Correct! x is incremented once
    cout << "[3] "<< x << endl;
    ans = safe(f()); // Correct! f() is called once
    cout << "[4] "<< x << endl;
    }

    void main(void)
    {
    userCode(100);
    }

    I was doing a test code for inline functions comparison to macros. The original code was shown as above, things seemed normal as the result showed two times of f() calls. The result looked like:

    [1] 102
    Called f();
    Called f();
    [2] 102
    [3] 103
    Called f();
    [4] 103

    However, after I tried to call ans = (f()) >= 0 ? (f()) : -(f()); instead of ans = unsafe(f());, I got a result of calling f() FOUR times instead of TWO times as supposed. In this tread, I failed to attach a image of the result, which looked like:

    [1] 102
    Called f();
    Called f();
    Called f();
    Called f();
    [2] 102
    [3] 103
    Called f();
    [4] 103

    I ran the program twice both of times I got calling f() FOUR times, nevertheless, I could repeat the result after I re-compiled the program again with the original code. Could this be a compiler bug? DJ

    C / C++ / MFC help performance question

  • what wrong with this function template?
    D DengJW

    thanks for your quick reply. DJ

    C / C++ / MFC help debugging question workspace

  • what wrong with this function template?
    D DengJW

    thanks. my concern is why int max(int, int) not working but float max(float, float) working. What I had tested was funtion templates, not max/min funtion. So I renamed the function name to confuse less. The following codes work:

    #include
    template T TFun(T a, T b)
    {
    if (a > b)
    return(a);
    else
    return(b);
    }
    float TFun(float, float);
    //int TFun(int, int);
    void main(void)
    {
    std::cout << "The TFunimum of 100 and 200 is " <<
    TFun(100, 200) << '\n';
    std::cout << "The TFunimum of 5.4321 and 1.2345 is " <<
    TFun(5.4321, 1.2345) << '\n';
    }

    DJ

    C / C++ / MFC help debugging question workspace

  • what wrong with this function template?
    D DengJW

    What I have tried to test was how to use Function Template, then I copied a segment of codes from a book. If I left float TFun(float, float) uncommented, the code works well; however, if I left int TFun(int, int) uncommented, the code did not work. That is the problem I could not figure out.

    #include
    template T TFun(T a, T b)
    {
    if (a > b)
    return(a);
    else
    return(b);
    }
    float TFun(float, float);
    //int TFun(int, int);
    void main(void)
    {
    std::cout << "The TFunimum of 100 and 200 is " <<
    TFun(100, 200) << '\n';

    std::cout << "The TFunimum of 5.4321 and 1.2345 is " << 
     TFun(5.4321, 1.2345) << '\\n';
    

    }

    DJ

    C / C++ / MFC help debugging question workspace

  • what wrong with this function template?
    D DengJW

    but if I just comment out int maxf(int, int); , the code works. Moreover, if I comment out float maxf(float, float); , the code works too. DJ

    C / C++ / MFC help debugging question workspace

  • what wrong with this function template?
    D DengJW

    thanks a lots. now this code works: #include <iostream> template T max(T a, T b) { if (a > b) return(a); else return(b); } //float max(float, float); //int max(int, int); void main(void) { std::cout << "The maximum of 100 and 200 is " << max(100, 200) << '\n'; std::cout << "The maximum of 5.4321 and 1.2345 is " << max(5.4321, 1.2345) << '\n'; } but why the definition of two functions, which have been commented out, not working? BTW, I intended to make use of function template instead of max/min functions. DJ

    C / C++ / MFC help debugging question workspace

  • what wrong with this function template?
    D DengJW

    The purpose of this test code is to make use of function template, instead of max funtion, which happened to be here. HOwever, if comment out [int max(int, int);], leave [float max(float, float); ], the code works well. Seems something wrong to the int type? DJ

    C / C++ / MFC help debugging question workspace

  • what wrong with this function template?
    D DengJW

    #include template T max(T a, T b) { if (a > b) return(a); else return(b); } float max(float, float); int max(int, int); void main(void) { cout << "The maximum of 100 and 200 is " << max(100, 200) << endl; cout << "The maximum of 5.4321 and 1.2345 is " << max(5.4321, 1.2345) << endl; } --------------------Configuration: Max_Temp - Win32 Debug-------------------- Linking... Max_Temp.obj : error LNK2001: unresolved external symbol "int __cdecl max(int,int)" (?max@@YAHHH@Z) Debug/Max_Temp.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. The problem seems with 'int max(int, int);'; after comment this line, no linking error DJ

    C / C++ / MFC help debugging question workspace

  • what are differences when using RasDial and InternetDial?
    D DengJW

    Maybe the question is what are differences between RAS (remote access service) and Internet dialup connection on WIndows platform? DJ

    C / C++ / MFC question

  • Modem dialup to retrieve data from SQL 2000 Server...
    D DengJW

    Thanks a lots. The problem was caused by some OS modules corrupted in Win 2k. I changed to another SQL server on a third machine, now I can access via SQL Query Analyzer and my program. DJ

    C / C++ / MFC database sysadmin question

  • Though here is C++ but I have a database problem?
    D DengJW

    Thanks a lots. The problem was caused by some OS modules corrupted in Win 2k. I changed to another SQL server on a third machine, now I can access via SQL Query Analyzer and my program. JW DJ

    C / C++ / MFC database help c++ sql-server sysadmin

  • Though here is C++ but I have a database problem?
    D DengJW

    But what I had done was to dial up directly into the DB Server from the PC client. and from either side, I can ping successfully to each other. SO there is no firewall between the PC client and The DB Server. Any suggestion? JW DJ

    C / C++ / MFC database help c++ sql-server sysadmin

  • Modem dialup to retrieve data from SQL 2000 Server...
    D DengJW

    I tried the IP address in SQL QUERY Analyzer. It did not work either. I am trying to access using code: sDSN = "Provider=sqloledb;" &_ "Data Source=TEST\SEAN;" &_ "Initial Catalog=test;" & _ "User Id=sa;" &_ "Password=password" \ thanks DJ

    C / C++ / MFC database sysadmin question

  • Modem dialup to retrieve data from SQL 2000 Server...
    D DengJW

    thanks John, But the problem is after a dialup connection established between the PC Client and the DB Server, I could not login through The SQL Query Analyzer which resides on the PC side also. Error message says the DB ( on the DB Server) does not exist or access denied. COuld this be that the OS running on DB Server is Pro instead of win 2k Server? Any other ideas? JW DJ

    C / C++ / MFC database sysadmin question

  • Though here is C++ but I have a database problem?
    D DengJW

    Sorry I forgot the problem description itself. The problem is that after the PC client and DB Server (currently SQL 2000 sever running on WIndows 2k Pro) were connected via a dialin service, from the PC site I can not see the DB on the DB Server, nor could I login to the SQL residing on DB Server of course. ANy idea, again? JW DJ

    C / C++ / MFC database help c++ sql-server sysadmin

  • Modem dialup to retrieve data from SQL 2000 Server...
    D DengJW

    thank you Mr.Prakash, The concern is the project budget instead of the connection speed as data will not be that big. You also are welcome to read the next message posted by me about this issue. JW DJ

    C / C++ / MFC database sysadmin question

  • use modem dialup to retrieve data from SQL 2000 Server...
    D DengJW

    I am programming a program to use modem dialup to retrieve data from SQL 2000 Server... What would be a good solution for the connection betweeb a client PC and the server running SQL Server 2000? JW DJ

    Database database sql-server sysadmin question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups