array output

This is a discussion on array output within the C++ Programming forums, part of the General Programming Boards category; I have stored values in an array and I printed it out. The output looks like the following: 4 5 ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    yes - use space as a delimiter, not a new line
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,537
    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, 05:58 AM
  3. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 11:09 AM
  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, 12:44 PM

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