Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-22-2002, 12:08 AM   #1 (permalink)
Blaqb0x
Registered User
 
Blaqb0x's Avatar
 
Join Date: Jun 2002
Posts: 3
Blaqb0x is on a distinguished road
finding precision of data in file

Hi,

Suppose I had a data file with numbers of various precisions in an NxM array

23.0001 33.034 2.00

99 3.92 0

however I did not know this ahead of time.All I know is I have a file with an NxM array with numbers of some precision.

If I wanted to find out

-How many columns and rows there were
-And the finest precision of the whole set. (x10^-4 from the first number)

What would be the best way of doing this?

-Since a 'space' is the delimeter here could I count the number of spaces before the last number and add 1 to that to get the number of columns?

-I suppose to get the number of rows I could
to a get line and increment a variable everytime until I hit the EOF.

thanx,
Blaqb0x is offline   Reply With Quote
Old 09-24-2002, 11:01 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,705
redhead is on a distinguished road
strtok(), search for the whiutespaces in the lines, that counts the columns..

Or while reading, something like this:
Code:
int read = 0;
int a, b, c;
read = fscanf(file_pointer, "%d %d %d\n", &a, &b, &c);
if(read < 3)
   // error happened, or line didnt hold three integers.
else
   // success, we have our line, with three or more columns.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need your help about writing data to file john_tran Standard C, C++ 9 10-20-2004 04:43 AM
Implementing C++ file structure in C# IAmWeasel MS Technologies ( ASP, VB, C#, .NET ) 1 07-08-2004 07:38 AM


All times are GMT -8. The time now is 09:21 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting