Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int length(char *string)
- {
- int len = 0;
- while(*(string++) != '\0') len++;
- return len;
- }
- void unos (char *s) {
- char c;
- while (c=getchar(),c!='\n') *(s++)=c;
- *s='\0';
- }
- void cut(char *string, int indeks, int len)
- {
- int i;
- for(i = indeks; i <= length(string) - len; i++)
- {
- string[i] = string[i + len];
- }
- }
- void IzbaciKomentare (char *s) {
- int i;
- int poc=0, kraj=0;
- int duz=length(s);
- for (i=0; i<duz; i++) {
- if (s[i]=='/')
- {
- poc=i;
- i++;
- if (s[i]=='*')
- {
- i++;
- while (s[i]!='*') i++;
- i++;
- if (s[i]=='/') kraj=i+1;
- }
- else if (s[i]=='/')
- {
- i++;
- while (s[i]!='\0') i++;
- kraj=i;
- }
- cut (s,poc,kraj-poc);
- }
- }}
- int main () {
- char c[100];
- printf("Unesite recenicu: ");
- unos(c);
- IzbaciKomentare(c);
- printf("Recenica bez komentara: %s",c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement