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
M

mike7411

@mike7411
About
Posts
36
Topics
28
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • get_string memory leak?
    M mike7411

    This is their pseudocode for bubble sort: -------------------------------------------------------

    Repeat n-1 times
    For i from 0 to n–2
    If numbers[i] and numbers[i+1] out of order
    Swap them
    If no swaps
    Quit

    ------------------------------------------------------- Then, David Malan supposedly analyzed the running time by multiplying n-1 by n-2.

    C / C++ / MFC question com performance learning

  • get_string memory leak?
    M mike7411

    I am taking Harvard's CS50 class. We are learning C. They use their own library where you include cs50.h. There is a function called get_string that returns a string. I think it has a memory leak. I think this is the source code: https://github.com/cs50/libcs50/blob/main/src/cs50.c They are saying stuff like: string name = get_string("What is your name?"); Then, they never call free on the memory in main. Anyone know how the memory gets freed or if it is a leak? Thanks.

    C / C++ / MFC question com performance learning

  • strlen innards
    M mike7411

    Can someone explain to me in layman's terms how this function works? https://codebrowser.dev/glibc/glibc/string/strlen.c.html Thank you.

    C / C++ / MFC html question

  • Top 100 algorithm
    M mike7411

    Let's say you need to find the top 100 best-selling books out of a list of a million books. What is the appropriate algorithm? I thought it would be QuickSelect, but that only chooses one item. Thank you.

    Design and Architecture question algorithms

  • time-consuming insert operation
    M mike7411

    Let's say you have a table with an index on the field "username". Is it true that eventually you'll have some really time-consuming inserts when the hash table has to resize itself? Hash table resize is O(n), I think. Thanks.

    Database database data-structures cryptography question

  • Assembly Language forum
    M mike7411

    I don't see a forum for assembly. Can you create such a forum? Thanks.

    Site Bugs / Suggestions question

  • CREATE INDEX
    M mike7411

    I was looking at the documentation for CREATE INDEX in SQL: https://www.w3schools.com/sql/sql_create_index.asp

    CREATE INDEX index_name
    ON table_name (column1, column2, ...);

    I don't understand when you would create it for multiple columns. Let's say you did this:

    CREATE INDEX idx_pname ON Persons (LastName, FirstName);

    Does that create one index on two columns? Or, is that the same as creating two indexes? For instance, does that statement create two hashtables? Or one hashtable? Thank you.

    Database database com question

  • SQL behind the scenes
    M mike7411

    Let's say you have a SQL database with a table called USERS. Let's say it has 500,000 users in it. Let's say you do this:

    SELECT PASSWORD FROM USERS WHERE USER='bill.gates';

    Let's say there's no indices on the table. Does the database just do a linear search thru each user? Thank you.

    Database database question

  • user data system for a web-based e-mail service
    M mike7411

    Let's say you don't want to use a SQL database, but you want to create a user data system for a web-based e-mail service. You want to store the following data about each user: username password address alternate email address phone number What kind of data structure should you use? Thank you.

    Design and Architecture database question

  • large numbers
    M mike7411

    How do you separate large numbers in Java? I want to use something like commas. I think this works in C++, but it doesn't work in Java:

    int onebillion = 1'000'000'000;

    Anyone know? Thanks.

    Java c++ java question

  • passing 0 to a function
    M mike7411

    Are you saying that passing 0 doesn't return undefined? Thanks.

    JavaScript com question

  • viewing Java disassembly
    M mike7411

    For doubles, I believe there is a positive zero and a negative zero.

    Java java visual-studio algorithms question

  • passing 0 to a function
    M mike7411

    I am trying to help a lass with her JavaScript code. Take a look at this image she posted: https://pbs.twimg.com/media/GDpFl1SWcAA0jk1?format=jpg&name=small[^] She claims the blue lines next to console.log are the output. Does it make sense to you?

    JavaScript com question

  • passing 0 to a function
    M mike7411

    Does anyone know what happens if you pass 0 to this function? https://pbs.twimg.com/media/GDh5G70XcAAyqTv?format=jpg&name=small Thank you.

    JavaScript com question

  • viewing Java disassembly
    M mike7411

    I am in IntelliJ IDEA. I want to view the disassembly of this code to see if it does two comparisons:

    if (-0.0 == 0.0) System.out.println("they're equal");

    Based on searching, it sounds like IntelliJ can't do that. Anyone know of a Java IDE that can do this? Thank you.

    Java java visual-studio algorithms question

  • memory allocation failure
    M mike7411

    The class is right here: https://www.edx.org/learn/computer-programming/iitbombay-programming-basics Here is some code from the class:

    int main()
    {
    int numStudents;
    int * A;
    cin >> numStudents;
    A = new int[numStudents];
    if (A != NULL) { A[0] = 10; A[1] = 15;}
    return 0;
    }

    C / C++ / MFC c++ performance question

  • memory allocation failure
    M mike7411

    If a memory allocation with new fails in C++, should it return NULL or throw an exception? I have this code:

    #include
    #include
    #include
    using namespace std;

    int main() {
    try{
    char *p = new char[44'321'833'923];

     if (!p) {
        cout << "memory allocation failed";
        exit(1);
        
    }
    
    }
    catch(exception&e)
    {
        cout << "caught it." << e.what();
        exit(1);
    }
    catch (...)
    {
        cout << "caught exception;";
        exit(1);
    }
    
    
    return 0;
    

    }

    The class I'm taking says it returns NULL, but the code seems to throw an exception. Anyone know? Thanks.

    C / C++ / MFC c++ performance question

  • catching a divide-by-zero error
    M mike7411

    I am trying to catch a divide-by-zero error with the following code:

    #include
    using namespace std;

    int main() {
    try {
    int a = 0;
    int x = 5 / a;
    }
    catch (exception e)
    {
    cout << e.what() << endl;
    }
    catch (...)
    {
    cout << "caught ..." << endl;
    }

    }

    For some reason, neither of my catch blocks gets executed. Anyone know how to catch the exception? Thank you.

    C / C++ / MFC help tutorial question

  • !file trickiness
    M mike7411

    Interesting. I tried doing a "Step Into" on that line in the debugger, but it won't go to it. If I do a "Go to Definition", it goes to this in xiosbase:

    \_NODISCARD bool \_\_CLR\_OR\_THIS\_CALL operator!() const noexcept /\* strengthened \*/ {
        return fail();
    }
    

    However, I put a breakpoint there, and it doesn't break.

    C / C++ / MFC question performance help

  • !file trickiness
    M mike7411

    I have the following file code:

    #include
    #include
    using namespace std;

    int main() {

    //add code below this line
    
    string path = "student/text/readpractice.txt";
    
    try {
        ifstream file;
        file.open(path); //content of file goes into memory buffer
        if (!file) {
            throw runtime\_error("File failed to open.");
        }
        cout << file.rdbuf(); //read the buffered content
        file.close();
    }
    
    catch (exception& e) {
        cerr << e.what() << endl;
    }
    
    //add code above this line
    
    return 0;
    

    }

    Can someone help me understand how this line works:

    if (!file) {

    How can you use the exclamation point operator on what is probably a class? Is there some type of overloading that has occurred? I looked thru the code, and I couldn't find the ! point being overloaded. Any ideas? Thanks.

    C / C++ / MFC question performance help
  • Login

  • Don't have an account? Register

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