need help with char and ints in an array

This is a discussion on need help with char and ints in an array within the C Programming forums, part of the General Programming Boards category; below is a bit of a program that i am writing but at the moment im having a problem with ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    27

    need help with char and ints in an array

    below is a bit of a program that i am writing but at
    the moment im having a problem with the array

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    char start_board(char array[16]);
    
    
    int main (void)
    {
    	
    	char board[16];
    	int countdown = 5;
    
    	
    	
    	printf ("welcome to the block puzzle game\nyou must rearrange the numbers in to asending order\n\n");
    
    	start_board(board[16]);
    
    }
    
    char start_board(char array[16])
    {
    	int index = 0;
    	
    	char board[16] = {'1','2','3','4','5','6','8','12','9','10','7','X','13','14','11','15'};
    
    	for(index = 0;index<=15;index++)
    	{
    		if (index ==4||index ==8|| index ==12)
    		{
    			printf("\n");
    		}
    		printf ("%c  ", board[index]);
    	}
    
    	
    
    	return board[16];
    }
    How can i get the output to print the two digit numbers in the array and still shox the X when it pops up

    also i want to be able to scanf a integer and check if it is in the array although the array is in characters how would i do this

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,636
    the main problem is that you didn't learn the C language well enough before jumping into your project. I suggest you read a book on the subject (lot's of tutorials online, too) before proceeding any further.
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. convert char array to int array
    By skeme in forum C Programming
    Replies: 10
    Last Post: 09-07-2008, 10:37 PM
  2. Reading int's from file to array HELP plz
    By GARiMTO in forum C Programming
    Replies: 3
    Last Post: 12-14-2007, 05:12 AM
  3. Dictionary into a 2d Char Array... Problems.
    By Muzzaro in forum C Programming
    Replies: 10
    Last Post: 12-02-2006, 11:34 AM
  4. Dealing with ints that are in char array
    By Wiretron in forum C Programming
    Replies: 4
    Last Post: 05-15-2006, 04:06 PM
  5. Problem Putting INTs Into a CHAR Array
    By cram in forum C++ Programming
    Replies: 13
    Last Post: 10-13-2004, 07:53 AM

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