No output from this program

This is a discussion on No output from this program within the C Programming forums, part of the General Programming Boards category; Here's the problem: a. Write a C program that has a declaration in main() to store the string "Vacation is ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    10

    No output from this program

    Here's the problem:
    a. Write a C program that has a declaration in main() to store the string "Vacation is near" into an array named message. There should be a function call to display() that accepts mesage in a parameter named strng and then displays the message using the pointer notation *(strng + i).
    b. Modify this display() function to alter the address in message. Use the expression *strng rather than *(strng + i) to retrieve the correct statement.

    Here's the code I have so far:

    Code:
    #include <stdio.h>
    void display(char[]);
    int main()
    {
      char message[] = "Vacation is near";
      display (message);
    return 0;
    }
    
    void display(char strng[])
    {
    int i=0;
    while(*(strng + i) != '\0'
    {
    printf("%c", *(strng+i));
    i++;
    }
    printf("\n");
    return;
    }

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161

    Re: No output from this program

    Good job using code tags! Now use indentation to make the code more readable.

    Do you have a question? So far it looks fine to me.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    10
    The problem is whenever I run the program I just get a blank window. It doesn't print out the vacation is near statement and I'm not sure why??

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    Me neither. Works for me once it compiled properly.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling an external program + capture output?
    By cyberfish in forum C++ Programming
    Replies: 4
    Last Post: 03-21-2008, 12:49 AM
  2. program looping with final output
    By hebali in forum C Programming
    Replies: 24
    Last Post: 02-28-2008, 09:58 AM
  3. Unusual program Output, Help
    By capvirgo in forum C Programming
    Replies: 8
    Last Post: 02-06-2008, 02:13 AM
  4. Redirecting program output straight to an edit control
    By bennyandthejets in forum C++ Programming
    Replies: 5
    Last Post: 07-05-2004, 08:25 AM
  5. Program Output
    By lavon in forum C Programming
    Replies: 1
    Last Post: 03-19-2002, 09:32 PM

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