Title: Implementation of a so library filename called a listupper.so,so file implements a function with the function named void Upper (constchar char *desc),
When update is called, all characters in the string pointed to by the parameter src are converted to uppercase letters, and the result is placed in the DESC string. Write a program test1 in C language respectively,
Call the upper function in libupper.so, write a program test2 in the C + + language, and invoke the upper function in libupper.so.
Upper.h
// compatible with g++ compilers #ifdef __cplusplus extern " C " {#endifvoid Upper (constChar * src,char *desc); Ifdef __cplusplus}#endif
Upper.c
/*based on function signature analysis, DESC is called function to allocate memory*/#include<stdio.h>voidUpperConst Char* SRC,Char*desc) { if(src==null| | desc==NULL) {printf ("the incoming parameter cannot be empty! \ n"); return; } while(*src) { if(*src> the&&*src<123) { //indicates that the character is a lowercase letter*desc++=*src- +; SRC++; }Else { *desc++=*src++; } }}
test1.c
#include <stdio.h>#include<unistd.h>#include"Upper.h"intMainintArgChar*args[]) {printf ("Please enter a string no more than 100 bytes in size! \ n"); Charbuf[ -]={0}; Chardesc[ -]={0}; intnum=0; Num=read (Stdin_fileno,buf,sizeof(BUF)); if(num==0)return 0; Upper (BUF,DESC); printf ("\ n The string that the user entered is:%s", DESC); return 0;}
Run results
Linux Linux program Exercise VI