Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need to program this in C - any help this is the starter code below: Part 2: argshift. [70 points] argshift is a program that

need to program this in C - any help

image text in transcribed

this is the starter code below:image text in transcribed

Part 2: argshift. [70 points] argshift is a program that takes a string as input, and shifts each letter in it forward by one letter (except z, which gets converted back to a). So, "abcz" should turn into "boda". This includes capital letters, but does not include non-alphabetical characetrs, such as punctuation, spaces and digits. For this, you should implement the following functions: char shift_char (char c) char* dup_shift (char* s) See the source code for more information about what each function should do. The memory space allocated for storing the return string should be dynamically allocated from the heap You should allocate the least amount of space that can still hold the result. Your code should not change the string s For this part you may use the standard library functions malloc, calloc, realloc, free and printf to manage dynamic memory allocation/deallocation and print the result After you implement the function strdup-ptr) correctly, your code should work as in the sample runs listed below: $./argshift Enter a string: Ludicrous Speed, Go! Mvejdspvt Tqffe, Hp! You should fix all memory leaks (if any) in the code. It is highly recommended that you look at an ASCII chart when doing this assignment. One may be found by running man ascii #include 3 #include 4 // return the length of a string 5 // For example, 6 // return if s is" // return 3 ifs is "abc" 8 unsigned long my_strlen(char *s) unsigned long while (*s +) return i; i-e; This should shift the 'a. to 'b', 'b' to 'c', , '2' to 'a', as well as the capital letters 19 Don 't shift non-alphabetical characters 1 char shift_char (char x)f 23 25 Returns a pointer to a new string which is 26a copy of the given string s./ 7 char dup_shift(char* s) f 28 29 0 int main(int argc, char argv[]) 2 char input[100]; 3 printf("Enter a string: ) scanf("%[^ ]s", input ) ; 5 char* dups_ptr-dup_-shift(input); printf("%s ", dups-ptr); 7 free (dups_ptr); 8 9 return 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

6. Does your speech have a clear and logical structure?

Answered: 1 week ago