Thread: Header to get int arrays???

  1. #1
    Ianelar Azure
    Guest

    Question Header to get int arrays???

    I know you use "gets(array);" to get char arrays.......whats the header to get int arrays? Or is even the header thats the problem? the header to use "gets(array);" is "#include<stdio.h>", is there a different one to get int arrays? Any info would be helpful everyone.

    Thank You
    Ianelar Azure
    Beginner Programmer on C++

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    a char array is a special type of array in many cases called a string, and that is what gets() is meant to get. In many cases we must input whole words and sentences, not single characters, that is why functions like gets() have been created to input entire arrays of chars, or strings.

    To input an array of ints, just do this:

    int array [ arraySize ];
    for ( int x = 0; x < arraySize; x++)
    {
    cin >> array[x];
    }
    My Website

    "Circular logic is good because it is."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. NEED HELP READING FILE and PRINTING
    By geoffr0 in forum C Programming
    Replies: 4
    Last Post: 04-16-2009, 05:26 PM
  2. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  3. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  4. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM