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 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

I am looking for a light-weight map component that displays a map of the
I have a script which is posting some form data to a Quickbase and
I've tried looking at a bunch of forums, and despite a lot of tweaking
I have an array of a large structure that I am trying to output
I created an h1 element that gets a class added to it and removed
Greetings StackOverflowians, As discovered here , Windows 7 features a bug in which the
This is a slightly abstract question, for which I apologize. I am not necessarily
Building a django app with some mostly static pages at the front of the
A little while ago I read a great article which described a number of
This is a design question, assuming C++ and a reference counted object hierarchy. A

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.