Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main (void){
  5. char a[1000];
  6. FILE *fptr;
  7. int i=0,j,len;
  8. if ((fptr=fopen("se.txt","r"))==NULL){
  9. printf("Error! opening file");
  10. exit(1); }
  11. fscanf(fptr,"%[^\0]",a);
  12. char *token;
  13. char *search ="#";
  14. token = strtok(a, search);
  15. token = strtok(NULL, search);
  16. while(token!=NULL){
  17. printf("<");
  18. i=0;
  19. if (token[0]==99){
  20. token[0]=8;
  21. printf("center> %s </center>",token);
  22.  
  23. }
  24. else if (token[0]==121) {
  25. token[0]=8;
  26. printf("!--%s-->\n",token);
  27. }
  28. else {
  29. while (i<strlen(token)){
  30. if (token[i]==32){
  31. token[i]=62;
  32. break;
  33. }
  34. i++;
  35. }
  36. printf("%s",token);
  37. switch (token[0]){
  38. case 'p':
  39. printf("</p>\n");
  40. break;
  41. case 'h':
  42. printf("</h1>\n");
  43. break;
  44. case 'b':
  45. printf("</b>\n");
  46. break;
  47. default :
  48. break;
  49. }
  50. }
  51. token=strtok(NULL,search);
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement