Ascii Art

This is a discussion on Ascii Art within the C Programming forums, part of the General Programming Boards category; I need help!! a program that uses data from a file to fill an array of structures, then uses these ...

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    3

    Ascii Art

    I need help!!

    a program that uses data from a file to fill an array of structures, then uses these to put icons pictures on the screen. I must use a structure definition:

    , then read and store all the icon data before displaying them on the screen. Ok I know how to call to files thats cool and I know how to create functions. I am not sure how to use the data from the file and fill an array of structures. So can someone help me?

  2. #2
    Registered User
    Join Date
    Feb 2004
    Posts
    3

    Ascii Art Part2

    The code did not attach so here it is
    Attached Files Attached Files
    • File Type: c main.c (549 Bytes, 226 views)

  3. #3
    WDT
    WDT is offline
    Tha 1 Sick RAT
    Join Date
    Dec 2003
    Posts
    271

    Cool Errr......

    we can help you but you'd first have to say how far with the work you've gone and what problems you're having.
    Remember we're not here to do your homework just to help you learn. so post what it is you want help with and we'll help.
    A hundred Elephants can knock down the walls of a fortress... One diseased rat can kill everyone inside

  4. #4
    WDT
    WDT is offline
    Tha 1 Sick RAT
    Join Date
    Dec 2003
    Posts
    271
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <ctype.h>
    void atbash(char *in, char *out); 
     
    int main(void) 
    {
    	char out[100];
        atbash("abcdefghijklmnopqrstuvwxyz", out);//You're passing this by value, hence you'll never see output on screen
    	
    	printf("%s", out);
    	getchar();
    	return 0;
    }
    void atbash(char *in, char *out)
    {
        int len = strlen(in);   /*en holds length of encrypt*/
    
        for (len--; len >= 0; len--){
            *out =  in[len];
            out++; Also i removed the * as that is a reference to the value not the memory address which is what you want to be incrementing
        }
        *out = '\0';   /*ULL terminiate*/
    }
    Last edited by WDT; 03-09-2004 at 10:29 PM.
    A hundred Elephants can knock down the walls of a fortress... One diseased rat can kill everyone inside

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    atbash("abcdefghijklmnopqrstuvwxyz", out);//You're passing this by value, hence you'll never see output on screen
    1) Every array is passed as a pointer to a memory address and not passed by value. This includes constant arrays. Only way to get around this is to put it inside a structure and pass the structure.

    2) When making comments on someone's code please make sure to use proper comment codes and try to avoid long sentences so it won't cause horizontal scrolling.

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Every array is passed as a pointer to a memory address and not passed by value.
    Technically an array isn't passed at all. A pointer to the first element is passed by value. You can then use pointer arithmetic to get to the rest of the array.
    My best code is written with the delete key.

  7. #7
    WDT
    WDT is offline
    Tha 1 Sick RAT
    Join Date
    Dec 2003
    Posts
    271
    Sorry my mistake, prelude's right. In anycase discard that thought, I knew that but I actually don't know why I wrote that. (Must be the wrong time of day to post @ 0429hrs. ) The last correction applies and then pause the console, e.g. getchar(); before the return statement in main and you should be able to see the results.
    A hundred Elephants can knock down the walls of a fortress... One diseased rat can kill everyone inside

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ascii Art program
    By brown in forum C Programming
    Replies: 2
    Last Post: 04-13-2009, 01:41 AM
  2. Replies: 11
    Last Post: 03-24-2006, 11:26 AM
  3. ASCII Art Decoder and Encoder
    By jessweetd in forum C Programming
    Replies: 7
    Last Post: 09-05-2004, 08:12 PM
  4. ASCII Art
    By Korhedron in forum Game Programming
    Replies: 4
    Last Post: 01-02-2003, 09:48 AM
  5. ASCII art source code.
    By Brian in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 02-19-2002, 02:25 PM

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