#include "stdafx.h"
#include <stdio.h>
#define TRUE 1
#define FALSE -1
#define STRING_SIZE 256
int startPoint = 0;
int endPoint = 0;
int checkComment(char *);
int stOutput(char *);
int main()
{
char str[STRING_SIZE];
int i = 0;
int comment;
printf("文字を入力したください。\n");
scanf("%s",&str);
comment = checkComment(str);
if(comment == TRUE)
{
stOutput(str);
}
/*
for(i = 0; str[i] != NULL; i++)
{
printf("%c",str[i]);
}
printf("\n");
*/
return 0;
}
int checkComment(char *str)
{
int i = 0;
int startComment = 0;
int endComment = 0;
int checkComment = 0;
for(i = 0; str[i] != NULL; i++)
{
printf("%c",str[i]);
if(str[i] =='/' && str[i+1] =='*')
{
//printf(" /* を発見!!\n");
startComment = TRUE;
startPoint = i;
}
if(startComment == TRUE && str[i] =='*' && str[i+1] =='/')
{
//printf(" */ を発見!!\n");
endComment = TRUE;
endPoint = i + 2;
}
}
printf("\n");
checkComment = startComment * endComment;
return checkComment;
}
int stOutput(char *str)
{
int i = 0;
int j = 0;
//printf("stOutput\n");
for(i = 0; i < startPoint; i++)
{
printf("%c",str[i]);
}
for(j = endPoint; str[j] != NULL ; j++)
{
printf("%c",str[j]);
}
printf("\n");
return 0;
}
0 件のコメント:
コメントを投稿