•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 373,565 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,859 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
hello frnd this a c program that removes c c++ style comments
//program to print a file by removing comments /*program*/ #include<stdio.h> void main(int argc , char *argv[]) { FILE *fp,*fp1; char ch; clrscr(); fp=fopen(argv[1],"r"); fp1=fopen(argv[2],"w"); while(1) { ch=fgetc(fp); /*fgetc*/ if(ch==EOF) //eof break; else { if(ch=='/') { ch=fgetc(fp); if(ch=='/') { while(1) { ch=fgetc(fp); if(ch=='\n') goto label; } } if(ch=='*') { while(1) { ch=fgetc(fp); if(ch=='*') { ch=fgetc(fp); if(ch=='/') { while(1) { ch=fgetc(fp); goto label; } } else printf("*"); } } } else printf("/"); } } label:fputc(ch,fp1); } fclose(fp); /*closes the file*/ fclose(fp1); }
Comments (Newest First)
thungmail | Newbie Poster | Feb 11th, 2008
•
•
•
•
hi
why you declare:
char =ch;
and then
ch=fgetc(fp);
I dont understand because fgetc(fp)'s return type is integer, but ch is char.
Tuan
why you declare:
char =ch;
and then
ch=fgetc(fp);
I dont understand because fgetc(fp)'s return type is integer, but ch is char.
Tuan
hobbes78 | Newbie Poster | Dec 18th, 2007
•
•
•
•
Humm... This will fail on a program as simple as:
C++ Syntax (Toggle Plain Text)
#include <iostream> use namespace std; int main(int argc, char *argv[]) { cout << "http://www.google.com/" << endl; return 0; }
niki01 | Newbie Poster | Nov 19th, 2007
•
•
•
•
Hi I'm writing a Program in C++, I believe the program is well written because the program was without error or warning. My problem is the program will not execute. I don't why it will not and don't know what to do. Please help me out.
jain_arhant | Newbie Poster | Oct 29th, 2007
•
•
•
•
is it possible to remove the goto statement in the code ?
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)