473,549 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to count rows and columns of integers/doubles in a file?

Hi,

I have some files which has the following content:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

I'm making a function for a bigger program, that

1) counts number of columns in each row
2) verifies that there are the same number of columns in each row
(if not: error + quit)
3) increments row count after one row is finished
4) stops execution if it encounters anything that is not an
integer (later: should also work for doubles)

My only problem is that I don't know how to switch line (carriage
return) or how to detect it using scanf. Besides that, the
program is almost finished. See below:
- - - - - - - - - - - - - - - -
#include <stdio.h>
void int_getdata(cha r *filename, unsigned int *x, unsigned int
*y);
int main()
{
unsigned int n_x[3], n_y[3];

int_getdata("un knowns.dat", &n_x[0], &n_y[0] );
int_getdata("BC _types.dat", &n_x[1], &n_y[1] );
// double_getdata( "BC_values.dat" , &n_x[2], &n_y[2] );

return 0;
}

void int_getdata(cha r *filename, unsigned int *x, unsigned int
*y)
{
FILE *fp;

unsigned int old_nx;
int int_readvalue, returnvalue;
//double double_readvalu e;

old_nx = 0; /* reset */
*x = 0;
*y = 0;

if ( (fp = fopen(filename, "r") ) == NULL)
{
printf("Cannot open file %s.\n", filename);
system("PAUSE") ; /* give the user at chance to see this
error before the windows shuts down */
exit(1);
}

/* get nx and ny */
do{
returnvalue = fscanf(fp, "%i", &int_readvalue) ; /* all
input must be valid */

if(returnvalue == 1) (*x)++; /* nx is getting larger */
else{
printf("Error: non-valid input found in %s.\n",
filename);
exit(1);
}

if(int_readvalu e == '\n')
{
if(old_nx != 0 && old_nx != *x)
{
printf("ERROR: nx is not a constant in file
%s!\n", filename);
exit(1);
}
else /* we should now be sure that nx is constant and
move on to the next input line */
{
old_nx = *x;
y++; /* ny is getting larger */
*x = 0;
}
}
} while(returnval ue != EOF);

printf("\nFinis hed reading from file %s: (x,y) = (%i,%i).\n",
filename, *x, *y);
fclose(fp); /* close input file, finished reading values in
*/
}

- - - - - - - - - - - - - - - -

I hope somebody can help me solve this small problem, so I can
finish the program....

I also get these small warnings, but they are not critical:

warning C4013: 'system' undefined; assuming extern returning int

warning C4013: 'exit' undefined; assuming extern returning int
Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk

Mar 15 '06 #1
68 6769
Martin Joergensen schrieb:
I have some files which has the following content:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

I'm making a function for a bigger program, that

1) counts number of columns in each row
2) verifies that there are the same number of columns in each row (if
not: error + quit)
3) increments row count after one row is finished
4) stops execution if it encounters anything that is not an integer
(later: should also work for doubles)

My only problem is that I don't know how to switch line (carriage
return) or how to detect it using scanf.
The end of a line is indicated by '\n' in C.
If you are writing the file with a C programme, too, and
the reading and the writing programme are in the same locale,
then you do not have to take care of anything as long as you
work with text streams. Only if you explicitly open a binary
stream, then you have to look at the actual representation
of '\n'.
So, you can read in the number of lines and columns like this
if you concentrate on 1) to 3). You need some sort of string
buffer for 4) if you do not want to check yourself.

int countRowsAndCol s (FILE *pFile, unsigned *pRows, unsigned *pCols)
{
unsigned rows, cols, oldcols;
int isConsistent = 1;

/* define file here */

rows = 0;
if (countColsInNex tLine(pFile, &oldcols) != EOF) {
rows++;
while (countColsInNex tLine(pFile, &cols) != EOF) {
rows++;
if (cols != oldcols) {
isConsistent = 0;
/* Your error message here */
}
}
}

*pRows = rows;
*pCols = oldcols;
return !isConsistent;
}

In
int countColsInNext Line (FILE *pFile, unsigned *pCols)
{
int c;
unsigned cols = 0;

do {
c = getc(pFile);
if (c != EOF && !isspace(c)) {
cols++;
do {
c = getc(pFile);
} while (c != EOF && !isspace(c));
}
while (c != EOF && c != '\n' && isspace(c)) {
c = getc(pFile);
}
} while (c != EOF && c != '\n')

*pCols = cols;
return c;
}
you consume characters from the file until you find
either a line break or the end of the file.
You return the last result from getc(), i.e. EOF if the
file ends. The functions are not tested.
You could make life easier in the second function by
introducing appropriate auxiliary functions.
The above is not tested.
Besides that, the program is
almost finished. See below:
- - - - - - - - - - - - - - - -
#include <stdio.h>
void int_getdata(cha r *filename, unsigned int *x, unsigned int *y);
int main()
{
unsigned int n_x[3], n_y[3];

int_getdata("un knowns.dat", &n_x[0], &n_y[0] );
int_getdata("BC _types.dat", &n_x[1], &n_y[1] );
// double_getdata( "BC_values.dat" , &n_x[2], &n_y[2] );

return 0;
}

void int_getdata(cha r *filename, unsigned int *x, unsigned int *y)
{
FILE *fp;

unsigned int old_nx;
int int_readvalue, returnvalue;
//double double_readvalu e;

old_nx = 0; /* reset */
*x = 0;
*y = 0;

if ( (fp = fopen(filename, "r") ) == NULL)
{
printf("Cannot open file %s.\n", filename);
system("PAUSE") ; /* give the user at chance to see this error
before the windows shuts down */
exit(1);
}

/* get nx and ny */
do{
returnvalue = fscanf(fp, "%i", &int_readvalue) ; /* all input must
be valid */

if(returnvalue == 1) (*x)++; /* nx is getting larger */
else{
printf("Error: non-valid input found in %s.\n", filename);
exit(1);
}

if(int_readvalu e == '\n')
This is not what you want. You compare the value of the read
integer against the value of the int constant '\n'.
{
if(old_nx != 0 && old_nx != *x)
{
printf("ERROR: nx is not a constant in file %s!\n",
filename);
exit(1);
}
else /* we should now be sure that nx is constant and move on
to the next input line */
{
old_nx = *x;
y++; /* ny is getting larger */
*x = 0;
}
}
} while(returnval ue != EOF);

printf("\nFinis hed reading from file %s: (x,y) = (%i,%i).\n",
filename, *x, *y);
fclose(fp); /* close input file, finished reading values in */
}

- - - - - - - - - - - - - - - -

I hope somebody can help me solve this small problem, so I can finish
the program....
Even though you can do certain things with the help of
scan sets (%[] or %[^]), it is probably easier to read in
a line and check the values with sscanf() or even strtoul()
or strtod(). If you only need the originally indicated
space -- non-space distinction, have a look at the suggested
functions.
We already lead the "how to read a line" discussion, so you
can just look up the respective thread.

I also get these small warnings, but they are not critical:

warning C4013: 'system' undefined; assuming extern returning int

warning C4013: 'exit' undefined; assuming extern returning int


They are. You forgot to #include <stddef.h>, so you did not get
proper types for the functions.
Especially, the arguments are not converted automatically and
you don't get a warning if they cannot be converted. For these
two functions, everything probably will work as intended but
there is a serious error behind the warning.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 15 '06 #2
"Martin Joergensen" <un*********@sp am.jay.net> writes:
I have some files which has the following content:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

I'm making a function for a bigger program, that

1) counts number of columns in each row
What do you mean by "columns"? Does "0 0 0 0 0 0" have 6 columns
(numbers) or 11 (characters)?

[snip]
returnvalue = fscanf(fp, "%i", &int_readvalue) ; /* all input
must be valid */


fscanf with a "%i" format reads an integer value after skipping any
leading whitespace -- including new-lines. It gives no indication of
what it skipped. If new-lines are significant, that's the wrong
approach.

It also accepts either decimal, octal, or hexadecimal input. Decide
whether you want to allow numbers like "0xff", and whether you want
"0123" to be interpreted in octal (yielding 83) or in decimal
(yielding 123). Since you mentioned you'll eventually want the
program to work with doubles, you probably don't want to accept octal
or hexadecimal; you probably want "%d" rather than "%i". ("%d" and
"%i" behave identically for the *printf functions, but differently for
the *scanf functions).

A much better approach is to use fgets() to read a line at a time,
then use sscanf() to scan the resulting line. sscanf(), unlike
fscanf(), doesn't consume its input; it's still there in the string,
and if the sscanf() call fails (check its returned value), you can try
again.

fgets() has the disadvantage that it can only read a line up to a
specified length. If the input line is longer than what you
specified, fgets() will read only part of it; you can detect this by
whether the line you just read ends in a '\n'. If you only want to
allow input lines up to some maximum length, this isn't much of a
problem -- but you should still decide what to do if an input line
exceeds your maximum. If you want to handle arbitrarily long input
lines, you can use CBFalconer's "ggets" (Google it).

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 15 '06 #3
On Wed, 15 Mar 2006 20:32:04 +0100, "Martin Joergensen"
<un*********@sp am.jay.net> wrote:
Hi,

I have some files which has the following content:

0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0

I'm making a function for a bigger program, that

1) counts number of columns in each row
2) verifies that there are the same number of columns in each row
(if not: error + quit)
3) increments row count after one row is finished
4) stops execution if it encounters anything that is not an
integer (later: should also work for doubles)

My only problem is that I don't know how to switch line (carriage
return) or how to detect it using scanf. Besides that, the
program is almost finished. See below:
- - - - - - - - - - - - - - - -
#include <stdio.h>
void int_getdata(cha r *filename, unsigned int *x, unsigned int
*y);
int main()
{
unsigned int n_x[3], n_y[3];

int_getdata("un knowns.dat", &n_x[0], &n_y[0] );
int_getdata("BC _types.dat", &n_x[1], &n_y[1] );
// double_getdata( "BC_values.dat" , &n_x[2], &n_y[2] );

return 0;
}

void int_getdata(cha r *filename, unsigned int *x, unsigned int
*y)
{
FILE *fp;

unsigned int old_nx;
int int_readvalue, returnvalue;
//double double_readvalu e;

old_nx = 0; /* reset */
*x = 0;
*y = 0;

if ( (fp = fopen(filename, "r") ) == NULL)
{
printf("Cannot open file %s.\n", filename);
system("PAUSE") ; /* give the user at chance to see this
error before the windows shuts down */
exit(1);
}

/* get nx and ny */
do{
returnvalue = fscanf(fp, "%i", &int_readvalue) ; /* all
input must be valid */
fscanf will eat white space, including the \n that marks the end of
line.

You could use fgets to get a complete line then strtol to process each
value for correctness.

if(returnvalue == 1) (*x)++; /* nx is getting larger */
else{
printf("Error: non-valid input found in %s.\n",
filename);
exit(1);
}

if(int_readvalu e == '\n')
{
if(old_nx != 0 && old_nx != *x)
{
printf("ERROR: nx is not a constant in file
%s!\n", filename);
exit(1);
}
else /* we should now be sure that nx is constant and
move on to the next input line */
{
old_nx = *x;
y++; /* ny is getting larger */
*x = 0;
}
}
} while(returnval ue != EOF);

printf("\nFinis hed reading from file %s: (x,y) = (%i,%i).\n",
filename, *x, *y);
fclose(fp); /* close input file, finished reading values in
*/
}

- - - - - - - - - - - - - - - -

I hope somebody can help me solve this small problem, so I can
finish the program....

I also get these small warnings, but they are not critical:

warning C4013: 'system' undefined; assuming extern returning int

warning C4013: 'exit' undefined; assuming extern returning int
Best regards / Med venlig hilsen
Martin Jørgensen

Remove del for email
Mar 16 '06 #4
"Michael Mair" <Mi**********@i nvalid.invalid> skrev i en
meddelelse news:47******** ****@individual .net...
Martin Joergensen schrieb: -snip-
The above is not tested.
Thanks... Helped me a lot... Almost finished now... Se my other
post.
if(int_readvalu e == '\n')


This is not what you want. You compare the value of the read
integer against the value of the int constant '\n'.


Oh, yeah... I hoped that it could read integers as well as
'\n'... Seems like it can't. I just skips it..

-snip- Even though you can do certain things with the help of
scan sets (%[] or %[^]), it is probably easier to read in
a line and check the values with sscanf() or even strtoul()
or strtod(). If you only need the originally indicated
space -- non-space distinction, have a look at the suggested
functions.
Ok... I added a little - I also want to skip commas.

That was also so great about scanf, that it could check if all
numbers were valid at the same time it counted...
We already lead the "how to read a line" discussion, so you
can just look up the respective thread.
I found something on google:
- - - - -- -
#define LENGTH 20
#define str(x) # x
#define xstr(x) str(x)

int rc;
char array[LENGTH + 1];
rc = scanf("%" xstr(LENGTH) "[^\n]%*[^\n]", array);
if (!feof(stdin)) {
getchar();
}
if (rc == 0) {
*array = '\0';
}
/* rc will be either 1, 0, or EOF */

- - - - -

What the hell is happening here: "[^\n]%*[^\n]" ?
I also get these small warnings, but they are not critical:

warning C4013: 'system' undefined; assuming extern returning
int

warning C4013: 'exit' undefined; assuming extern returning int


They are. You forgot to #include <stddef.h>, so you did not get
proper types for the functions.


No, I think it is stdlib.h, I needed... But thanks - you're
always a big help to me...
Especially, the arguments are not converted automatically and
you don't get a warning if they cannot be converted. For these
two functions, everything probably will work as intended but
there is a serious error behind the warning.


Ok, including stdlib.h seems to work...
Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk

Mar 16 '06 #5
"Keith Thompson" <ks***@mib.or g> skrev i en meddelelse
news:ln******** ****@nuthaus.mi b.org...
"Martin Joergensen" <un*********@sp am.jay.net> writes: -snip- A much better approach is to use fgets() to read a line at a
time,
then use sscanf() to scan the resulting line. sscanf(), unlike
fscanf(), doesn't consume its input; it's still there in the
string,
and if the sscanf() call fails (check its returned value), you
can try
again.

-snip-

What do you think about the following, based on Michael Mair's
proposal?

Just copy/paste - compiles well...
- - - - - -
#include <stdlib.h> /* system("PAUSE") */
#include <stdio.h>
#include <stddef.h>
#include <ctype.h> /* for isspace */

#define number_of_files 3

/* prototypes */
void getdata(char *filename, unsigned *pRows, unsigned *pCols);
/* this is how the args should be */
int countColsInNext Line (FILE *pFile, unsigned *pCols);
int main()
{
int i;
unsigned n_x[number_of_files], n_y[number_of_files]; /* one
space for each data file */

getdata("unknow ns.dat", &n_x[0], &n_y[0] );
getdata("BC_typ es.dat", &n_x[1], &n_y[1] );
// getdata("BC_val ues.dat", &n_x[2], &n_y[2] );

for(i=0; i<number_of_fil es; i++)
printf("Data file number %i has properties: x = %u, y=
%u\n", i, n_x[i], n_y[i]);

return 0;
}

//fgets( stringbuffer, 20, fp);
//sscanf( stringbuffer, "%X", &var1);

void getdata(char *filename, unsigned *pRows, unsigned *pCols) /*
this is how the args should be */
{
FILE *pFile;

unsigned rows, cols, oldcols;

if ( (pFile = fopen(filename, "r") ) == NULL)
{
printf("Cannot open file %s.\n", filename);
system("PAUSE") ; /* give the user at chance to see this
error before the windows shuts down */
exit(1);
}

*pRows = 0;
*pCols = 0;

/* get nx and ny */
cols = 0;
rows = 0;
if (countColsInNex tLine(pFile, &oldcols) != EOF) { /* get
oldcols for first row */
rows++;
while (countColsInNex tLine(pFile, &cols) != EOF) {
rows++;
if (cols != oldcols) { /* verify that number of cols
didn't change */
printf("ERROR: Number of columns is not a
constant in file: %s!\n", filename);
exit(1);
}
}
}

*pRows = rows; /* update results */
*pCols = oldcols;

printf("\nFinis hed reading from file %s.\n", filename);
fclose(pFile); /* close input file, finished reading values
in */
}

int countColsInNext Line (FILE *pFile, unsigned *pCols)
{
int c;
unsigned cols = 0;

do {
c = getc(pFile); /* get first character to start the loop
*/
if (c != EOF && !isspace(c)) { /* first time non-space
encountered, update cols */
cols++;
do { /* skip digits and commas */
c = getc(pFile);
} while (c != EOF && !isspace(c) && c != ',' && c !=
'.'); /* comma should also be valid input in number */
}
while (c != EOF && c != '\n' && isspace(c)) { /* skip
through spaces, but not '\n' ! */
c = getc(pFile);
}
} while (c != EOF && c != '\n');

*pCols = cols;
return c;
}
- - - -
It seems like there is small error in counting the rows..... I
couldn't find the error before and I'm not sure I understood all
the while loops completely - to help myself I added some
comments.

So there's just a little error left (that's the second time in
this thread I write that - This time I hope it's true!) :-)
Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk

Mar 16 '06 #6
Martin Joergensen wrote:
"Keith Thompson" <ks***@mib.or g> skrev i en meddelelse
news:ln******** ****@nuthaus.mi b.org... -snip-
What do you think about the following, based on Michael Mair's proposal?

-snip-

I don't know why, but I can't debug that code very well... I put
breakpoints in it but very often within the getdata-function, it just
finishes the program ignoring my breakpoints....

Why is that so?
Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Mar 16 '06 #7
Martin Jørgensen wrote:
Martin Joergensen wrote:
"Keith Thompson" <ks***@mib.or g> skrev i en meddelelse
news:ln******** ****@nuthaus.mi b.org...


-snip-
What do you think about the following, based on Michael Mair's proposal?


-snip-

I don't know why, but I can't debug that code very well... I put
breakpoints in it but very often within the getdata-function, it just
finishes the program ignoring my breakpoints....

Why is that so?


Forget it... I forgot to add a compiler option and now it works.
Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Mar 17 '06 #8
Martin Joergensen schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> skrev i en meddelelse
news:47******** ****@individual .net...
Martin Joergensen schrieb: <snip>
rc = scanf("%" xstr(LENGTH) "[^\n]%*[^\n]", array); <snip> What the hell is happening here: "[^\n]%*[^\n]" ?


read up to LENGTH non-'\n' characters into array, consume
arbitrarily many subsequent '\n's
I also get these small warnings, but they are not critical:

warning C4013: 'system' undefined; assuming extern returning int

warning C4013: 'exit' undefined; assuming extern returning int


They are. You forgot to #include <stddef.h>, so you did not get
proper types for the functions.


No, I think it is stdlib.h, I needed... But thanks - you're always a big
help to me...


"Left, left -- oh, I meant the other left"
Of course, you are right: I meant <stdlib.h>

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 17 '06 #9
Michael Mair wrote:
-snip-
Cheers
Michael


Do you like my new program?

I find it *REALLY* useful :-)

- - - - - - - - - - - -

#include <stdlib.h> /* system("PAUSE") */
#include <stdio.h>
#include <stddef.h>
#include <ctype.h> /* for isspace */

#define max_number_of_f iles 50

/* prototypes */
void getdata(char *filename, unsigned *pCols, unsigned *pRows, int *count);
int countColsInNext Line (FILE *pFile, unsigned *pCols, unsigned *pRows);
void testwronginput( int c, unsigned cols, unsigned rows);

int main()
{
int i, count;
unsigned n_x[max_number_of_f iles], n_y[max_number_of_f iles]; /* one
space for each data file */

count = 0;
getdata("unknow ns.dat", &n_x[0], &n_y[0], &count );
getdata("BC_typ es.dat", &n_x[1], &n_y[1], &count );
getdata("BC_val ues.dat", &n_x[2], &n_y[2], &count );

for(i=0; i<count; i++)
printf("Data file number %i has properties: Columns (x) = %u,
Rows y= %u\n", i+1, n_x[i], n_y[i]);

system("PAUSE") ; /* give the user at chance to see this error
before the windows shuts down */
return 0;
}
void getdata(char *filename, unsigned *pCols, unsigned *pRows, int *count)
{
FILE *pFile;

unsigned rows, cols, oldcols;

printf("Opening file: %s.\n", filename);
if ( (pFile = fopen(filename, "r") ) == NULL)
{
printf("Cannot open file %s.\n", filename);
system("PAUSE") ; /* give the user at chance to see this error
before the windows shuts down */
exit(1);
}

*pRows = 0;
*pCols = 0;

/* get nx and ny */
cols = 0;
rows = 0;
if (countColsInNex tLine(pFile, &oldcols, &rows) != EOF) { /* return
oldcols for first row */
rows++;
while (countColsInNex tLine(pFile, &cols, &rows) != EOF) { /*
check row 2 -> EOF */
rows++;
if (cols != oldcols) { /* verify that number of cols didn't
change */
printf("ERROR: Number of columns is not a constant in
file: %s\n\n", filename);
printf("In line %u, the number of columns is %u
cols.\n", rows, cols);
printf("In the previous line it was counted to
%u.\n\nPlease fix this problem now.\n", oldcols);
exit(1);
}
}
}

if (cols != 0 && cols != oldcols) {
printf("ERROR: Line %u (last line) consisted of %u
columns.\nLine %u had %u columns.\n", rows, cols, rows-1, oldcols);
exit(1);
}

*pRows = rows; /* update results */
*pCols = oldcols;
(*count)++;

printf("Finishe d reading from file %s.\n\n", filename);
fclose(pFile); /* close input file, finished reading values in */
}

int countColsInNext Line (FILE *pFile, unsigned *pCols, unsigned *pRows)
{
int c;
unsigned cols = 0;

c = getc(pFile); /* get first character to start the loop */
do {
testwronginput( c, cols, *pRows);
if (c != EOF && !isspace(c)) { /* first time non-space
encountered, update cols */
cols++;
do { /* skip digits and commas, after first digit */
c = getc(pFile);
testwronginput( c, cols, *pRows);
} while (c != EOF && !isspace(c) || c == ',' || c == '.');
/* comma should also be valid input in number */
}
while (c != EOF && c != '\n' && isspace(c)) { /* skip through
blank spaces, but not '\n' ! */
c = getc(pFile);
testwronginput( c, cols, *pRows);
}
} while (c != EOF && c != '\n'); /* is the line finished or is EOF
reached? */

*pCols = cols;
return c;
}

void testwronginput( int c, unsigned cols, unsigned rows) /* I tried
isblank() but my system complained about it */
{
if (isalpha(c)) {
printf("Error! Alphabetic character '%c' encountered before
EOF\n", c);
printf("Last succesful location read was: Line %u, Column
%u\n", 1+rows, cols);
system("PAUSE") ; /* give the user at chance to see this error
before the windows shuts down */
exit(1);
}
if (iscntrl(c) && c != 10) {
printf("Error! Control character '%c' encountered before
EOF\n", c);
printf("Last succesful location read was: Line %u, Column
%u\n", 1+rows, cols);
system("PAUSE") ; /* give the user at chance to see this error
before the windows shuts down */
exit(1);
}
if (!isprint(c) && c != EOF && c != '\n') {
printf("Error! Non-printing character '%c' encountered before
EOF\n", c);
printf("Last succesful location read was: Line %u, Column
%u\n", 1+rows, cols);
system("PAUSE") ; /* give the user at chance to see this error
before the windows shuts down */
exit(1);
}
}

- - - - - - - - - - - -
Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Mar 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1582
by: Dejavous | last post by:
Hi there, I'm a SQL Server 2000 noob and looking for some help. I need to make a simple script that counts the number of rows in a table. Also, i need to make another version ofthe same script, but ONLY look and count rows with certain data in them...e.g. search and count for rows with the word JOE in them. Any help would be really...
1
1451
by: dukefrancis | last post by:
Can anyone tell me how to find the count of columns from a table????
3
1542
by: sheesh | last post by:
hi how am i able to input rows of integers from another file for eg num.txt inside the text file it is as shown 1 3 5 2 4 6 7 9 11 i tried doing so but still couldn't get it string s;
1
1326
by: neehakale | last post by:
If anybody of you knows how to count the no of rows in the excel file then pls tel me....
0
2987
by: JFKJr | last post by:
I have an excel file, which has columns C and D grouped together, I am trying to delete blank columns and rows from the excel file, ungroup the columns and import the file to MS Access using Access VBA code. The following is the Access VBA code I used to delete blank columns and rows in the excel file. But, unfortunately, the resultant excel...
1
1875
by: mojo123 | last post by:
Hi All, I am looking for a way to count rows in datagrid. The code I have goes something like this: Data1.DatabaseName = Mydata.mdb Data1.Recordsoource = Select * Table1 Where Class = 3 And Group=2 Data1.Refresh How can I count the number of current rows/record in a datagrid. Any Help will be greatl appreciated.
6
2901
by: viki1967 | last post by:
Hi all. I need your help. I realize this script and I do not know where to begin: 1) A simple grid rows / columns. 2) The first column contain an input type = "checkbox" 3) When select the input type, the line should change color than the other rows, and you should open a popup window.
3
7033
by: ronakinuk | last post by:
how can i unhide rows/columns in excel 2007
0
7480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7992
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7840
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6088
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1973
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1087
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.