JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums Algorithm Matches SRM 715 Programme not getting executed
 Programme not getting executed | Reply this is the question - InputYou are given a single line of text, with length at most 1000 characters. The text consists of English words. Adjacent words in the line are separated by a single space.The second line consists of a single integer 'N' denoting the width of an output line.OutputPrint the input text in the following format:no line of output must be more than N characters long.no word can be split across two lines. If a word does not completely fit in a line, move the word to the next line.Sample InputO SOFT embalmer of the still midnight Shutting with careful fingers 34Sample OutputO SOFT embalmer of the still midnight Shutting with careful fingers////////////////////////////////////////////////////////////////////////////////MY CODE : #include#include#includeusing namespace std;void print(char str[],int *start,int i){ for(int j= *start;j<=i;j++) { cout<<<"\n";}int main(){ char str[1000]; int start=0; stackspace; cin.getline(str,1000); int l=strlen(str); if(l<=33) { puts(str); exit(0); } for(int i=0;str[i]!='\0';i++) { if(i%33==0 && str[i]==' ') { print(str,&start,i); space.push(i); } else if(i%33==0 && str[i] != ' ') { int lastspace=space.top(); if(space.empty()!=1) { print(str,&start,lastspace); i=lastspace+1;} } else if(str[i]== ' ') { space.push(i); } } print(str,&start,l-1); return 0; }Problem is it's not showing any error while compiling but when it's not getting executed in Dev c++ 5.11. Online compilation shows that it's some segmentation error . Pls help me where i have gone wrong
 Re: Programme not getting executed (response to post by ayush.b.1998) | Reply sorry for remark but first of all format your code please. There is \[cpp\] \[/cpp\] markup for syntax highlighting too for c/c++ sources.
 Forums Algorithm Matches SRM 715 Programme not getting executed Previous Thread  |  Next Thread