Variable sized objects!!

This is a discussion on Variable sized objects!! within the C Programming forums, part of the General Programming Boards category; Hi!! I don't get this!! My compiler says that variable sized object 'temp' (which happen to be an array of ...

  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,185
    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, 10: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, 10:01 PM
  4. Need help
    By awkeller in forum C Programming
    Replies: 2
    Last Post: 12-09-2001, 02:02 PM
  5. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 01:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21