The line count of what? A file? An image? User input? If text you could just count the number of newline characters (which can be /r, /n, or /r/n).seriypshick said:Is there a function in C that would display the line count?
The souce file (Ex. test.c)HiRez said:The line count of what? A file? An image? User input? If text you could just count the number of newline characters (which can be /r, /n, or /r/n).
#define ; {printf("Line # is %i", line_number_function()}
You could do something like:seriypshick said:The souce file (Ex. test.c)
Basically what i want to do is to print line number plus some other info for every line, or after each ; (semicolon).
Code:#define ; {printf("Line # is %i", line_number_function()}
int line_number_function() {
static int linenum;
return linenum++;
}
nl test.c
I wouldn't do it if I didn't own a mac. But owning a mac doesn't mean you have to do programming in objective-C. There's plenty of other languages you could use and not all mac users are programmers (obviously). It's is a very nice development platform and the tools are free.NewbieNerd said:Do many people do much Obj-C programming just because they own a Mac? Seems like a nice language though I haven't used it much.
seriypshick said:The souce file (Ex. test.c)
Basically what i want to do is to print line number plus some other info for every line, or after each ; (semicolon).
Code:#define ; {printf("Line # is %i", line_number_function()}
/*
* File: line_number.c
* Compile this file with gcc -c line_number.c
*/
int linenum = 0;
extern int line_number() {
return linenum++;
}
/*
* File: test.c
* Compile this file with gcc -o linenum test.c line_number.o
*/
#define LINNUM printf("Line # is %i\n", line_number());
extern int line_number();
main() {
int foo=0; LINNUM
while(foo<10) { LINNUM
foo++; LINNUM
}
}
Thank's I think that's what I need.AlmostThere said:I don't know what the original poster is trying to achieve but no-one seems to have mentioned the standard C macro __LINE__, which just expands to the current line number.