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

  • Home
  • SEARCH
  • 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 3313524
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:07:32+00:00 2026-05-17T22:07:32+00:00

Just looking to be pointed in the right direction: Have standard input to a

  • 0

Just looking to be pointed in the right direction:

Have standard input to a C program, I’ve taken each line in at a time and storing in a char[].

Now that I have the char[], how do I take the last word (just assuming separated by a space) and then convert to lowercase?

I’ve tried this but it just hangs the program:

while (sscanf(line, "%s", word) == 1)
    printf("%s\n", word);

Taken what was suggested and came up with this, is there a more efficient way of doing this?

char* last = strrchr(line, ' ')+1;

while (*last != '\0'){   
    *last = tolower(*last);
    putchar((int)*last);
    last++;
}
  • 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-17T22:07:32+00:00Added an answer on May 17, 2026 at 10:07 pm

    If I had to do this, I’d probably start with strrchr. That should get you the beginning of the last word. From there it’s a simple matter of walking through characters and converting to lower case. Oh, there is the minor detail that you’d have to delete any trailing space characters first.

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

Sidebar

Related Questions

Looking to be pointed in the right direction to create the ie. someone emails
Looking for a method or to be pointed in the right direction so I
Im looking to be pointed in the right direction. My site that i'm testign
I was just skimming the C99 standard, looking for something that I don't remember
We just started learning windows programming in C++. We have to make a program
Just looking for a good PHP Image Library, I want to display images with
Just looking on resources that break down how frames per second work. I know
I just looking how to use LINQ for grouping a list. Class Item Public
Basically just looking to see if you can capture an image from the webcam
I was just looking at this example from Deitel : #include <stdio.h> struct card

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.