Thread: Variable sized objects!!

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    103

    Variable sized objects!!

    Hi!!
    I don't get this!!
    My compiler says that variable sized object 'temp' (which happen to be an array of struct) may not be initialised.
    Code:
                                                int account_number = 0 ,choice2;
                                                printf("\nHow many accounts you want to add?");
                                                scanf("%d",&choice2);
                                                account_number += choice2;
                                                account temp[account_number];
                                                for (int i = 0 ; i < choice2 ; i++)
                                                                   account temp [i] = add_account();

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    And if you just type "temp[i] = add_account()" does that work?

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    103
    It did!!
    Thank you so much!
    That was bugging me for hours!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 60
    Last Post: 12-20-2005, 11:36 PM
  2. Replies: 4
    Last Post: 10-16-2003, 11:26 AM
  3. variable sized arrays: compiler specific?
    By dirkduck in forum C++ Programming
    Replies: 6
    Last Post: 01-24-2002, 11:01 PM
  4. Need help
    By awkeller in forum C Programming
    Replies: 2
    Last Post: 12-09-2001, 03:02 PM
  5. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 02:26 PM