CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: need help!!!^^

  1. #1
    Join Date
    Jul 2009
    Posts
    6

    need help!!!^^

    how to use array Allow the user to specify the number of inputs to be used (up to a maximum number)??
    is it something like this??

    const int SIZE = 30;
    int a[SIZE];
    int i,n,h;

    cout<<"Enter the number of Reistor except Rf:";
    cin>>n;

    for(i=0;i<n;i++)
    {
    cout<<"Enter the resistance of R"<<a[i];
    cin>>h;
    }
    return 0;
    }

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: need help!!!^^

    #include <vector> and use a std::vector<int>.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: need help!!!^^

    If you have a known maximum number, then there's no need to get vectors involved. Simply store that maximum in a variable somewhere. The fact that the array is bigger than that doesn't matter---you simply ignore any slots in it beyond that value.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured