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 that shortens a string (sentence of words) at requested
I wrote this function that I want to use in a program, but for
i wrote a function that takes a string as input. function ajaxLoad(targetBox, loadUrl) {
I wrote a function that builds an XML string based on the data saved
I wrote a function that gives me the length of a dynamic array by
I wrote a function that scans a tab delimited file of baseball stats. public
I've got a function I wrote quite some time ago that works fine, but
i want to write a function that prints multi-dimensional objects which are text (or
I want to write 'twice' function that takes a function and an argument and
I want to write a function that read line by line from a socket

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.