Question

In: Computer Science

in C programming language char character [100] = "hello"; a string array variable It is given....

in C programming language

char character [100] = "hello"; a string array variable
It is given. By writing a function called TranslateString,
By accessing the pointer address of this given string,
returning the string's address (pointer address) by reversing the string
Write the function and use it on the main function. Function void
will not be written as. Return value pointer address
it will be. Sweat operation on the same variable (character)
It will be made. Declaration of the function is as follows
Consider; “char * TranslateString (char * str);”

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

#include<stdio.h>
#include<string.h>

char* TranslateString(char* str){
  
  
   int front = 0, rear = strlen(str)-1;
   char temp;
   while(front<rear){
       temp = *(str+front);
       *(str+front) = *(str+rear);
       *(str+rear) = temp;
      
       front++;
       rear--;
      
      
   }
   return str;
  
  
}

int main(){
  
   char character[100] ="hello" ;
  
   char* reverse = TranslateString(character) ;
   printf("Reverse String: %s", reverse) ;
}

=====================================================================


Related Solutions

. Consider the character array as follows: char mySentence[] = "Hello World!"; The number of characters...
. Consider the character array as follows: char mySentence[] = "Hello World!"; The number of characters in the array can be determined by application of the strlen() function. Therefore, the end of the array can be determined by pointer arithmetic as follows: char * endArray = mySentence + strlen(mySentence); Now that the end of the array has been determined, utilise pointers in C++ to output each character in array in reverse and display it to the console window. What other...
C Implement the function Append (char** s1, char** s2) that appends the second character array to...
C Implement the function Append (char** s1, char** s2) that appends the second character array to the first, replaces the first array with the result and replaces the second character array with the original first array. For example, if the first character array is "hello" and the second is "world" at the end of the function the new value of the first character array should be"helloworld" and the second array should be "hello". If the input is invalid the function...
*C PROGRAMMING LANGUAGE* a) Given an array of size n, sort the array using pointers using...
*C PROGRAMMING LANGUAGE* a) Given an array of size n, sort the array using pointers using malloc or calloc. Examples: Input: n = 5, A= {33,21,2,55,4} Output: {2,4,21,33,55} b) Write a function that declares an array of 256 doubles and initializes each element in the array to have a value equal to half of the index of that element. That is, the value at index 0 should be 0.0, the value at index 1 should be 0.5, the value at...
(In C language) Given a two-dimensional char array, how do I encode it into a one...
(In C language) Given a two-dimensional char array, how do I encode it into a one dimensional integer array? For example: char arr [8][8] = {{1,1,1,1,1,1,1,1}, {1,0,0,0,1,0,0,1}, {1,0,1,0,1,1,0,1}, {1,0,1,0,0,0,0,1}, {1,0,1,1,1,1,0,1}, {1,0,0,0,0,0,0,1}, {1,0,1,0,1,0,1,1}, {1,1,1,1,1,1,1,1}} into int arr2 [8] I know this problem requires bit-shifting but I am unsure how. It also needs to be as efficient as possible. Thanks!
Write in C programming language Write the function replace(char b[], char f[], char t[]). which finds...
Write in C programming language Write the function replace(char b[], char f[], char t[]). which finds the string 'f' in the string 'b' and replaces it with the string 't'. You can assume that f and t same length Example: char string[] = "zap";     replace(string, "ap", "oo"); --changes 'string' to "zoo".     *don't assume substring being replaced is singular, or that its own substrings are unique.     *Don't re scan letters already checked and replaced         char string[] =...
in C programming language Write a function removeDups that removes all duplicates in a given array...
in C programming language Write a function removeDups that removes all duplicates in a given array of type int. Sample Test Case: input -> {1,2,2,2,3,3,4,2,4,5,6,6} output -> {1,2,3,4,5,6,0,0,0,0,0,0} More specifically, the algorithm should only keep the first occurance of each element in the array, in the order they appear. In order to keep the array at the same length, we will replace the removed elements with zeros, and move them to the end of the array.
C Programming Language Please Given a string S and keyword string K, encrypt S using keyword...
C Programming Language Please Given a string S and keyword string K, encrypt S using keyword Cipher algorithm. Note: The encryption only works on alphabets. Numbers and symbols such as 1 to 9, -, &, $ etc remain unencrypted. Input:     Zombie Here     secret     where: First line represents the unencrypted string S. Second line represents the keyword string K. Output:     ZLJEFT DTOT Explanation: We used "secret" keyword there. Plain Text: A B C D E F G H I J K...
A certain programming language allows only two-character variable names. The first character must be a letter...
A certain programming language allows only two-character variable names. The first character must be a letter (upper or lower case) and the second character can be a letter (upper or lower case) or a digit. How many possible variable names are there?
Write in C++ programming language Given the following postfix string, from left to right, use the...
Write in C++ programming language Given the following postfix string, from left to right, use the stack push operation to put items on the stack and the pop operation whenever an operator is encountered and to get two items and apply the operator to the operands then push back the result to evaluate the expression … rewrite the entire stack as it appears before each operator is applied. 12 3  / 5  + 32 2  3  ^  2  *  /  -
This is C++ programming Given an int variable k, an int array incompletes that has been...
This is C++ programming Given an int variable k, an int array incompletes that has been declared and initialized, an int variable nIncompletes that contains the number of elements in the array, an int variable studentID that has been initialized, and an int variable numberOfIncompletes, Write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes. You may use only k, incompletes, nIncompletes, studentID, and numberOfIncompletes. I tried this code...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT