How to convert C++ code to C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • creatigent@gmail.com

    How to convert C++ code to C#

    How to convert this code to C#, Thanks

    char ID[21];

    ID[20]='\0';

    srand((long) time(NULL));

    char Result[43];

    // ID 1-3
    memcpy(Result,I D,3);

    // 2 random digits
    sprintf(&Result[3],"%2.2d",rand() %100);

  • Arne Vajhøj

    #2
    Re: How to convert C++ code to C#

    creatigent@gmai l.com wrote:
    How to convert this code to C#, Thanks
    >
    char ID[21];
    >
    ID[20]='\0';
    >
    srand((long) time(NULL));
    >
    char Result[43];
    >
    // ID 1-3
    memcpy(Result,I D,3);
    >
    // 2 random digits
    sprintf(&Result[3],"%2.2d",rand() %100);
    Random rng = new Random();
    string result = "***" + String.Format(" {0:2}",rng.Next (100));

    where "***" is replacing the 3 uninitialized bytes
    containing random bytes from the stack in the C++ code.

    Arne

    Comment

    Working...