reverse pinter review

reverse pinter review - // main function //...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 // **************************************************************** // // reverse.cpp // // This program inputs a C-String from the user and then // reverses the contents of the string using character pointers. // // **************************************************************** #include <iostream> #include <cstdlib> #include <cstring> using namespace std // ======================
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // main function // ====================== int main() { char s[80] char temp char *head = NULL, *tail = NULL cout << "Enter a string less than 80 characters long." << endl cin.getline(s,80) head = s tail= head + strlen(s) - 1 while (head<tail) { temp=*head *head=*tail *tail=temp head++ tail--} cout << "Your string reversed is :" << s << endl return 0 } Sheet1 Page 2...
View Full Document

This note was uploaded on 04/12/2009 for the course CS 31 taught by Professor Melkanoff during the Winter '00 term at UCLA.

Page1 / 2

reverse pinter review - // main function //...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online