当前位置: 中原健康网 -> 新闻资讯

EIE110编程代做、C/C++程序设计代做

时间:2021-01-08 08:43    来源: 中原健康网   作者:苏秦 阅读量:5648   会员投稿

EIE110编程代做、C/C++程序设计代做

Homework 3 -- String Functions

CS110/EIE110/LP101 2020 Fall

1 Introduction

There are many interesting functions on strings that we can implement, for example the famous

Caesar Cipher can encrypt and decrypt strings, whose idea is simply adding or subtracting a fixed

value from each character, as depicted by the above graph found from the internet

[1]

.

We will write a C program that will perform different operations on strings. The program is organized

using multiple functions and files. The emphasized knowledge aspects in this homework include the

following:

Function design and implementation

.c and .h files. A program with multiple files.

Friendly interaction between the computer and the user.

User's menu of choices

Show friendly and clear messages to a user.

Clear input queue when needed. This is a technique to avoid input confusion.

When user's input is wrong, show some error message, and ask the user to do input again.

Algorithms. We will implement some simple encryption and decryption algorithms.

2 Tasks of this homework

2.1 prepare multiple source files.

The program should have multiple files, whose names and brief descriptions are listed below.

myStrLib.h : function declarations (prototypes) of Section 2.2.

strShape.h : function declarations of Section 2.3.

strCypher.h : function declarations of Section 2.4.

strShape.c : function definitions of Section 2.2.

myStrLib.c : function definitions of Section 2.3.

strCypher.c : function definitions of Section 2.4.

driver.c : function definitions of Section 2.5

With these .h and .c files, a function defined in one .c file can be used by another .c file where the

corresponding .h file is included ( #included ).

2.2 Implement several string library functions

C standard library provide many helpful functions on string computation, they can be used including

the head string.h which contains the prototypes of these functions. In this homework we will

implement our versions of some string library functions, with the same parameters, return value, and

computation process as the standard library functions. At least three library functions should be

implemented, which are described by their prototype and comments as follows:

unsigned int my_strlen(const char str[]);

/* my version of the strlen() function.*/

char * my_strcpy( char *dest, const char *src);

/* my version of the strncpy() function

https://en.cppreference.com/w/c/string/byte/strcpy */

int my_strcmp(const char * str1, const char * str2);

/* my version of the strcmp() function.

https://en.cppreference.com/w/c/string/byte/strcmp */

In your program, the three library functions strlen , strcpy , and strcmp should not be used, they

should all be replaced by your versions.

In addition, you can implement other functions in string.h as you like Detailed documents of the

string library functions can be found online at some websites [2]

like www.cppreference.com .

2.3 Some design and implement several other tool functions

We wll design several functions related to string input and output. Their prototypes and computation

descriptions are as follows.

int input_long_str(char storage[], unsigned int sizeLimit, int endMark)

The function will record user's input from the keyboard. The input can contain white spaces

and multiple lines.

The recorded input is saved in the array storage as a true C string.

sizeLimit should be the size (number of elements) of storage . So, at most

sizeLimit - 1 characters of user's input can be recorded in storage , one more space

for the null character (

郑重声明:此文内容为本网站转载企业宣传资讯,目的在于传播更多信息,与本站立场无关。仅供读者参考,并请自行核实相关内容。