Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
c
Transcribed Image Text:Write a function reverse which takes a string as an argument, reverses the string and returns a new string that is the reverse of the original.
Note: you will need to malloc space for this new string!
For example:
Test
char str[]="hello";
char *rts reverse(str);
printf("%s/%s", str,rts);
Result
Answer: (penalty regime: 0 %)
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5
6
hello/olleh
char* reverse(char str[])
{
char *rts = (char*) malloc(strlen(str)* sizeof(char)); //allocating memory for pointer
7 char *start=rts; //starting address of pointer is stored in start
8 for(int i=strlen(str)-1;i>=0; i--) //traversing the str[] array from last to first
9-{
Check
10 *rts=str[i]; //storing the element of str[i] to rts
11
rts++; //incrementing pointer
12
}
13
return start; //rerturning starting address of the pointer
14
}
15
int main()
16 {
17 char str[100]="hello";
18 char *rts=reverse(str);
19 printf("%s/%s", str, rts);
20 return 0;
21}
Syntax Error(s)
_tester__.c:31:5: error: redefinition of 'main'
int main() {
ANNN
tester__.c:23:5: note: previous definition of 'main' was here
int main()
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 2 steps with 2 images
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Are you familiar with the many different programming languages? Please provide a summary of each one.arrow_forwardWhen acquiring proficiency in a novel programming language, what are two prevalent activities or concepts that are typically explored?arrow_forwardExplain the compiler's structure and how the code may be tested.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education