Results 1 to 2 of 2

Thread: Program hanging

  1. #1
    Join Date
    Jan 2012
    Beans
    160

    Program hanging

    I must be missing something here.

    Code:
    void Database_create(struct Connection *conn)
    {
        int i = 0;
          int total_addresses_used;
      
         printf("How many to store in this database?\n");
         scanf("%d", &total_addresses_used);
        
    
         for(i = 0; i < total_addresses_used; i++) {
                 printf("%d", i);
           struct Address addr = {.id = i, .set = 0};
           printf("119 debug.");
                conn->db->rows[i] = addr;
        }
         printf("DEbug");
         conn->db = realloc(conn->db, sizeof(struct Address) * total_addresses_used);
    
    }
    After running this function, after the value total_addresses_used is inputted, there is nothing. No debug output. Why is this hanging?

  2. #2
    Join Date
    Jul 2012
    Beans
    57

    Re: Program hanging

    Add a fflush(stdout) or possibly a newline character \n in the last printf.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •