answersLogoWhite

0


Best Answer

These should work, if used correctly.

// stores srcL + srcR into dest

// NOTE: dest must be at least as large as srcL + srcR

void strConcat(const char* srcL, const char* srcR, char* dest) {

const int lengthL = strLength(srcL);

const int lengthR = strLength(srcR);

// copy srcL into front of dest

int i;

for(i = 0; i < lengthL; ++i) {

dest[i] = srcL[i];

}

// copy srcR into the rest of dest

for(i = 0; i < lengthR; ++i) {

dest[lengthL + i] = srcR[i];

}

dest[lengthL + i] = '\0';

}

// copies characters from src to dest

// NOTE: dest must be at least as large as src

void strCopy(const char* src, char* dest) {

const int length = strLength(src);

// copy

int i;

for(i = 0; i < length; ++i) {

dest[i] = src[i];

}

}

// reverses str and puts the result in buff

// NOTE: buff must be at least as large as str

void strReverse(const char* str, char* buff) {

const int length = strLength(str);

// special case for zero-length strings

if( length == 0 ) {

return;

}

// reversify

int i;

for(i = 0; i < length; ++i) {

buff[i] = str[length - i - 1];

}

buff[i] = '\0';

}

// returns the number of characters in str

int strLength(const char* str) {

int length = 0;

// take advantage of the fact that all strings MUST end in a null character

while( str[length] != '\0' ) {

++length;

}

return length;

}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to implement the various operations on string such as length of string concatenation reverse of a string copy of a string to another in c anguage?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program to implement the various operations on string such as length of string concatenation reverse of a string copy of a string to another in VB?

what is string


Can interface implement the other interface?

No. An interface cannot implement another interface, it can only just extend it. Because, an interface cannot implement any method as it has no method body declarations.


What is Strowger Exchange?

It was the first generation of an automated telephone exchange used for routing calls from one line to another. Strowger was the first to implement electromechanical switches which removed the need for an operator to manually connect the telephone lines together.


What is the meaning of tools?

An instrument such as a hammer, saw, plane, file, and the like, used in the manual arts, to facilitate mechanical operations; any instrument used by a craftsman or laborer at his work; an implement; as, the tools of a joiner, smith, shoe-maker, etc.; also, a cutter, chisel, or other part of an instrument or machine that dresses work., A machine for cutting or shaping materials; -- also called machine tool., Hence, any instrument of use or service., A weapon., A person used as an instrument by another person; -- a word of reproach; as, men of intrigue have their tools, by whose agency they accomplish their purposes., To shape, form, or finish with a tool., To drive, as a coach.


Why java is considered as a low level language?

java is simple because the developers of java omitted the difficult concepts of pointers which is used in c &amp; c++ and another reason is that the developers wanted to implement this programming language in electronic devices,which have less memory