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 3596956
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:03:21+00:00 2026-05-18T20:03:21+00:00

I wrote a function that that shortens a string (sentence of words) at requested

  • 0

I wrote a function that that shortens a string (sentence of words) at requested length. I do not want that a the cut of the sentence happens to be in middle of a single word. So i skip back n chars until I reach a space and cut the sentence string there.
My problem is not really a problem, compiling my function spits out a warning that says “warning: value computed is not used”, see the commented line in the code. The function works as expected though.
So either I am blind, or I am sitting to long on my project, actually I do not understand that warning. Could anybody please point me the flaw in the function?


char *
str_cut(char *s, size_t len) {
    char *p = NULL;
    int n = 3;

    p = s + len;
    if (p < (s + strlen (s))) {
        /*
         * do not cut string in middle of a word.
         * if cut-point is no space, reducue string until space reached ...
         */
        if (*p != ' ')
            while (*p != ' ')
                *p--;   // TODO: triggers warning: warning: value computed is not used

        /* add space for dots and extra space, terminate string */
        p += n + 1;
        *p = '\0';

        /* append dots */
        while (n-- && (--p > s))
            *p = '.';
    }
    return s;
}

My compiler on the development machine is “gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4)”

  • 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-18T20:03:22+00:00Added an answer on May 18, 2026 at 8:03 pm

    The warning is due to the * (dereference) — you aren’t using the dereferenced value anywhere. Just make it:

    p--;
    

    and the warning should go away.

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

Sidebar

Related Questions

I wrote a function that gives me the length of a dynamic array by
I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000" .
I have this Array i wrote a function MostFreq that takes an array of
I wrote a managed C++ class that has the following function: void EndPointsMappingWrapper::GetLastError(char* strErrorMessage)
I wrote a sample program at http://codepad.org/ko8vVCDF that uses a template function. How do
I want to write a function that takes an array of letters as an
I want to write a function that accepts two objects as parameters and compare
I want to write a function that returns the nearest next power of 2
I want to write a function that accepts a parameter which can be either
I have a function that accepts a string, that is: void log_out(char *); In

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.