| delorie.com/archives/browse.cgi | search |
| From: | James W Sager Iii <sager+@andrew.cmu.edu> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Attempting to make an auto indenter |
| Date: | Sat, 17 Mar 2001 02:42:04 -0500 |
| Organization: | Carnegie Mellon, Pittsburgh, PA |
| Lines: | 54 |
| Message-ID: | <guglJAq00UjGEqYEcz@andrew.cmu.edu> |
| NNTP-Posting-Host: | po7.andrew.cmu.edu |
| X-Trace: | bb3.andrew.cmu.edu 984815178 3700 128.2.10.107 (17 Mar 2001 07:46:18 GMT) |
| X-Complaints-To: | advisor AT andrew DOT cmu DOT edu |
| NNTP-Posting-Date: | 17 Mar 2001 07:46:18 GMT |
| X-Added: | With Flames (outnews v2.6) |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Since I do not have the time to space out my code as I go along, I was
hoping to save time by making a program that takes as its argument a
C/C++ file and indents it automatically depending on {}. I'd really
like to see this feature in rhide, but since it does not exist, I need
to code it up.
My code however is buggy because I suck really badly at interfacing with
other people's code...
I can't even get my program to read in a line without getting extra
Ascii gibberish. Anyone have the code to read in a line of text out of
an Ascii text file? My code looks like this:
#include <iostream.h>
#include <stdio.h>
FILE *in;
char *getline(FILE *f1);
void main(void)
{
//using cut and pastest code I had from a genetics project...
//This is why I'm using enz(enzyme) for text holders
char enz[250];
char enz2[250];
in = fopen("test.txt", "rt");
while (!feof(in))
{
strcpy(enz,getline(in));
cout<<enz<<endl;
}
}
char *getline(FILE *f1)
{
//Assumes no line is greater than 256 characters
char c=0;
char line[256];
int i;
//Loop while not end of line
i=0;
while(c!=10)
{
c=fgetc(f1);
if(c!=10)
line[i]=c;
i++;
}
line[i]='\0';
return(line);
}
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |