Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TUT 10.
- 5.
- #include <stdio.h>
- char* ukloni_komentare(char* s)
- {
- char* pom = s;
- char* pocetak = s;
- char* tmp, *atm;
- while(*pom != '\0') {
- if(*pom == '/') {
- tmp = pom;
- atm = pom; // atm da se vratim na mjesto gdje je poceo komentar
- pom++;
- if(*pom == '/') {
- while(*pom != '\0' && *pom != '\n')
- pom++;
- while(*tmp++ = *pom++);
- pom = atm;
- continue;
- } else if(*pom == '*') {
- while(1) {
- pom++;
- if(*pom == '*'){
- pom++;
- if(*pom == '/'){
- pom++;
- while(*tmp++ = *pom++);
- pom = atm;
- break;
- }
- pom--;
- }
- if(*pom == '\0') break;
- }
- continue;
- }
- }
- pom++;
- }
- return pocetak;
- }
- int main()
- {
- char kod[] = "aa*/****/*/**/*/*/*/bb";
- printf("%s", ukloni_komentare(kod));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement