In C language, Write a function that gets a string containing a positive integer. The function subtracts 1 from that integer and puts the obtained value in the string. void str_subtract_one(char* num); For example: - if before we call str_subtract_one(str) we have str==“1997”, then after return str will be “1996”. - if before we call str_subtract_one(str) we have str==“12345678987650”, then after return str will be “12345678987649”. - if before we call str_subtract_one(str) we have str==“100”, then after return str will be “99”. 1. You may assume that the input is always legal, i.e., the string is a positive integer correctly formatted. 2. Note that the numbers may be larger than the maximum of int or long. That is, you should not try to convert string to int

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter9: Completing The Basics
Section9.3: The String Class
Problem 7E
icon
Related questions
Question

In C language, Write a function that gets a string containing a positive integer. The function subtracts 1 from
that integer and puts the obtained value in the string.

void str_subtract_one(char* num);

For example:
- if before we call str_subtract_one(str) we have str==“1997”, then after return str will be “1996”.
- if before we call str_subtract_one(str) we have str==“12345678987650”, then after return str will be “12345678987649”.
- if before we call str_subtract_one(str) we have str==“100”, then after return str will be “99”.

1. You may assume that the input is always legal, i.e., the string is a positive integer correctly formatted.
2. Note that the numbers may be larger than the maximum of int or long. That is, you should not try to convert string to int

Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning