Thread: array output

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    58

    array output

    I have stored values in an array and I printed it out. The output looks like the following:
    4
    5
    A
    9
    L


    I want my output prints in a horizantale line. Any one know how ?

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    yes - use space as a delimiter, not a new line
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    Can you give me an example ? because I am not quite sure about how to use it ?

    This is what I have:


    Code:
    void printCode()
    {
    	for(int i = 0; i< 13; i++)
    	{
    		
    		result+=billy[i];
    		//cout<<billy[i]<<endl;
    	}
    	
    	cout<<result<<endl;
    	return 0;
    }

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    okay, it could only work if my code contains all of one type but my code is all string? Once I set the result to a string type it sends an error.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Post actual code and actual error messages.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    If you do cout << something << endl you get a newline each time.
    Same with cout << something << "\n". But if you just do cout << something, then you don't get a new line.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Output an array in a textbox
    By Diablo02 in forum C# Programming
    Replies: 5
    Last Post: 10-18-2007, 03:56 AM
  2. Array output strange
    By swgh in forum C++ Programming
    Replies: 1
    Last Post: 12-09-2006, 06:58 AM
  3. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 12:09 PM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  5. Sorting array output problem
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 02-19-2002, 01:44 PM