prog3 - /* line 40 */ for(int i=0; i<=(s_length -...

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

View Full Document Right Arrow Icon
/* Matt Hergenrether CS2433 C/C++ Programming March 3, 2009 2:00pm */ #include <stdio.h> #include <string.h> #include <unistd.h> int split(char a[],char b[],char *c, char *d); /* function prototype */ void removep(char x[], char y[], char* z); /* function prototype */ void main(void) { /*declaring variables*/ char entered[250]; char LineIn[250]; char LineOut[250] = ""; /* line 20 */ char LineFinal[250] = ""; char equals_sign[] = "="; char bad_string[] = "&!@#$%&*+"; { removep(LineIn, bad_string, LineOut); printf("%s\n", LineOut); removep(LineOut, equals_sign, LineFinal); printf("%s\n", LineFinal); } } /*function searches for a pattern in a given string and removes it*/ int split(char s[], char p[], char *sl, char *sr) /* function definition */ { int s_length = strlen(s); int p_length = strlen(p); int count = 0;
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: /* line 40 */ for(int i=0; i<=(s_length - p_length); i++) { /* printf("%d\n", i);*/ for(int k=0; k<p_length; k++) { /* printf("%d\n", k );*/ if(s[i+k] == p[i+k]) { count++; } if(count == p_length) { for(int l=0; l<i; l++) { sl += s[l]; } for(int m=(i+k+1); m >= s_length; m++) { sr += s[m]; } /* line 60 */ return 1; } } } /* printf("%d\n", count);*/ /* printf("%s\n", s);*/ if(count != p_length) { sr = ""; /*69*/ sl = s; printf(" sl is %s\n", sl); printf(" sr is %s\n", sr); /*70*/ return 0; } } void removep(char s, char p, char *t) /*function definition */ { t = s; char right_string = ""; char left_string = ""; while(split(t, p, left_string, right_string )) { t = strcat(left_string, right_string); printf("%s\n", left_string); printf("%s\n", right_string); } }...
View Full Document

This note was uploaded on 09/28/2011 for the course CS 1113 taught by Professor Chandler during the Fall '08 term at Oklahoma State.

Page1 / 2

prog3 - /* line 40 */ for(int i=0; i<=(s_length -...

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