+ 11

my program cannot run in code playground ...

#include<iostream.h> #include<conio.h> #include<string.h> #include<ctype.h> #include<stdio.h> void main() { clrscr(); int ch,i,j,k=0,p=0,l; char st[50],sr[50]; cout<<"Enter Your Choice : "<<endl<<"1.Each Word Reversing"<<endl<<"2.Whole Sentence Reversing"<<endl; cin>>ch; switch(ch) { case 1: cout<<"Enter the String"<<endl; gets(st); l=strlen(st); for(i=0;i<=l;i++) { if((st[i]==' ')||(st[i]=='\0')) { for(j=i-1;j>=p;j--) { sr[k]=st[j]; k++; } sr[k]=' '; k++; p=i+1; } } for(i=0;i<p;i++) cout<<sr[i]; break; case 2: cout<<"Enter the String"<<endl; gets(st); l=strlen(st); p=l-1; for(i=l-1;i>=-1;i--) { if((st[i]==' ')||(i == -1)) { for(j=i+1;j<=p;j++) { sr[k]=st[j]; k++; } sr[k]=' '; k++; p=i-1; } } for(i=0;i<=l;i++) cout<<sr[i]; break; default: cout<<"Wrong Choice"<<endl; break; } getch(); }

9th Jul 2017, 7:15 AM
Hope
Hope - avatar
6 Answers
+ 8
Your code is obsolete, parts of it belongs to pre-standard C++, e.g. iostream.h instead of iostream, conio.h, void main instead of int main, missing standard namespaces, clrscr, getch, etc. https://www.sololearn.com/Discuss/288609/?ref=app
9th Jul 2017, 7:25 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
Many errors in this code, for starters there should be a space between your #include and the header names. main should also return 0. You did not add "using namespace std;" Also you can't use clrscr() on SL code playground.
9th Jul 2017, 7:25 AM
Karl T.
Karl T. - avatar
+ 3
@Hatsy How can you tell the code is turbo C++?
9th Jul 2017, 7:36 AM
Manual
Manual - avatar
+ 3
TCC has died long ago, just not some of its users. 😕
9th Jul 2017, 8:07 AM
Karl T.
Karl T. - avatar
+ 2
because he used getch () and clrscr() and used iostream.h instead of iostream
9th Jul 2017, 7:40 AM
‎ ‏‏‎Anonymous Guy
0
this version runs on sl play ground https://code.sololearn.com/cR4Ja8zVHI4Z/?ref=app
9th Jul 2017, 8:34 AM
‎ ‏‏‎Anonymous Guy