#include <stdio.h>
int main(void) {
FILE *fpr = fopen ("file.c", "r");
FILE *fprw = fopen ("new_file.c", "w");
if (fpr == NULL) {
printf("Error open file.c");
return 1;
}
if (fprw == NULL) {
printf("Error open new_file.c");
return 1;
}
char ch, nextch;
nextch = fgetc(fpr);
while (nextch != EOF) {
ch = nextch;
nextch = fgetc(fpr);
if ((ch == '/') && (nextch == '*')) {
ch = fgetc(fpr);
nextch = fgetc(fpr);
while (!((ch == '*') && (nextch == '/'))) {
ch = nextch;
nextch = fgetc(fpr);
}
nextch = fgetc(fpr);
continue;
} else if ((ch=='/') && (nextch == '/')) {
nextch = fgetc(fpr);
while (!(nextch == '\n')) {
nextch = fgetc(fpr);
}
nextch = fgetc(fpr);
continue;
}
putc(ch, fprw);
}
fclose (fpr);
fclose (fprw);
return 0;
}
/*
file.c
------
// #include <stdio.h>
//
// #define ROW 5
// #define COL 10
//
// void func(char *parr, int row, int col) {
// /*for (int i = 0; i < row; i++) {
// printf("%s\n", parr + sizeof(char) * col * i);
// }*/
// }
//
// int main(void) {
// char arr[ROW][COL] = {"c", "c++", "c#", "java", "python"};
//
// /* func((char*)arr, ROW, COL); */
//
// // one line comment
//
// return 0;
// }
//
//
//
// /*
// run:
//
// c
// c++
// c#
// java
// python
//
// */
/*
run:
#include <stdio.h>
#define ROW 5
#define COL 10
void func(char *parr, int row, int col) {
}
int main(void) {
char arr[ROW][COL] = {"c", "c++", "c#", "java", "python"};
return 0;
}
*/