Thread: help with code

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    16

    help with code

    I just started learning C, so please bear with my if my code is not all that great! So I am basically trying to print out "Start Typing >" utilizing lc4_puts(). Then I am trying to fall into a loop where it waits for me to type a character and then prints that character to the console. The program terminates when it encounters a line feed character char '/n'.So this is my code..

    Code:
     #include "os_trap_wrappers.h"
    
    #define STRING_SIZE 100
    
    
    int main(void)
    {
        char c, input[STRING_SIZE];
        int i;
    
    
    lc4_puts("Start Typing >");
    for (i = 0; (c = lc4_getc()) != '\n'; ++i) {
        input[i] = c;
    }
    
    
    input[i] = '\0';
    lc4_putc(input[i]);
    return 0;
    }
    and this is what is contained in my wrappers file

    Code:
     char lc4_getc();
    void lc4_putc(char c);
    void lc4_puts(char *str); 
    void lc4_draw_box(int x, int y, int size, int *colors);

    although my program compiles and my simulator displays start typing to the screen, i can't type after it. i don't know what could be wrong with my code! any guidance would help, thanks!
    Last edited by mgravier; 03-20-2013 at 05:28 PM.

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I didn't look over the code much, but this jumped right out at me:

    for (i = 0; (c = lc4_getc()) != '/n'; ++i)

    You have the wrong slash!

  3. #3
    Registered User
    Join Date
    Mar 2013
    Posts
    16
    awesome!! thank you so much! i am also getting an error saying that 'lc4_puts' is expected a ';' but i already have a semicolon. i don't know what it's referring to

  4. #4
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Check the line of code directly above that function call.

  5. #5
    Registered User
    Join Date
    Mar 2013
    Posts
    16
    ah, great! thank you very much!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 09-19-2012, 01:58 PM
  2. Replies: 14
    Last Post: 04-01-2008, 02:23 AM
  3. producing c/c++ code from flowcharts,pseudo code , algorithims
    By rohit83.ken in forum C++ Programming
    Replies: 3
    Last Post: 02-20-2008, 07:09 AM
  4. Having trouble translating psudeo-code to real-code.
    By Lithorien in forum C++ Programming
    Replies: 13
    Last Post: 10-05-2004, 07:51 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM

Tags for this Thread