Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5953889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:53:28+00:00 2026-05-22T17:53:28+00:00

Hey, yeah you guessed it homework. I am trying to print a string in

  • 0

Hey, yeah you guessed it homework. I am trying to print a string in reverse using pointers. Only the words though. So “hello world” is “olleh dlrow”.
What I’m doing in the code below is assigning one pointer(pSentence, which is a string array of multiple words passed down from the main function) to a temporary pointer until a space, then increment backwards and print the character from the temporary pointer to the beginning of the word, then do it again. I’m currently stuck, I don’t know how to mark the beginning of the word and increment only to that. I know the while(pt != ‘0’) is not the way to do it at all. The prompt says to store the word into a temporary string(tmpStrg) and use pT to point to it, so maybe I need to do something with tmpStrg? Any help is much appreciated and thank you in advance!!

void prtWords(char *pSentence)
{
    char tmpStrg[81], *pT=tmpStrg;
    int length=0;

    while(*pSentence != '\0')
    {
       while(*pSentence != ' ' && *pSentence != '/0')
       {
         *pT=*pSentence;
         pT++;
         pSentence++;
         length++;
       }
       pSentence++;

       while(length >= 0);
       {
         printf("%c", *pT);
         pT--;
         length--;
       }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:53:29+00:00Added an answer on May 22, 2026 at 5:53 pm
    void prtWords(char *pSentence)
    {
        char tmpStrg[81], *pT=tmpStrg;
    

    According to your code, I suppose here you use tmpStrg[81] as a new string for a word, and you print the word in reverse order later.

        int length=0;
        while(*pSentence != '\0')
        {
           while(*pSentence != ' ')
           {
    

    Here is your problem for overflow, you should test \0 and at the same time (and change the second while to a && with first while unchanged). There is no guarantee that a sentence will end with a .

             *pT=*pSentence;
             pT++;
             pSentence++;
             length++;
           }
           pSentence++;
           while(length >= 0);
    

    When length is 0, you should not do anything. Change to >.

           {
             printf("%c", *pT);
    

    You should do pT-- first, because last pT++ does not have an assignment.

             pT--;
             length--;
           }
    

    Here print a when *pSentence == ' '.

        }
    }
    

    Work out the full code yourself as it is homework. Any further questions are welcomed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I'm using Levenshteins algorithm to get distance between source and target string. also
Hey all i have an XML file that i am trying to loop though.
Hey, I am wondering how void pointers is applied in the real world in
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey right now I'm using jQuery and I have some global variables to hold
Hey having some trouble trying to maintain transparency on a png when i create
Hey guys I am making a terminal application using Swing and Apache Commons. I
I'm using Visual Studio 2008 with the October 2009 F# CTP installed. I'm trying
Hey guys here is my question. im using JCombobox. if a student have CB

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.