473,383 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

I want to write a c program opening text file containing data and convert in matrix

1
I want to write a c program which uses a text file containing 2 columns,
Using fopen() I opened the file but how to seperate the both columns in seperate arrays?
Sep 1 '10 #1
1 2019
Read 1 line using fread.
sscanf the line into the 2 arrays.
make sure you use the right format in sscanf.

sscanf ( readbytes, "<right format>", &array1[i],&array2[i] )
example:
Expand|Select|Wrap|Line Numbers
  1. char* str = "134;123";
  2. int a[1],b[1];
  3. sscanf(str,"%d;%d",&a[0],&b[0]);
(ps: dont forget the fclose)
Sep 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: burdeen | last post by:
I can't find any way of writing a unicode, or UTF-8 format text file. Right now i have a Unicode string that i write to the text file and the unicode characters are replaced with ANSI question...
3
by: NewToPHP | last post by:
I am COMPLETELY NEW TO PHP San someone supply me with a PHP script to read and write to a text file on the server Also any suggestion on a free PHP editor?
2
by: Liz | last post by:
Hi, Learning Java, want to play with XML. I have a text file that looks like this. # PER 2:04 AM 06/09/2003 # plotfile for a circle of radius 5 # at the origin but rotated 25 degrees about the...
2
by: Rudolf Bargholz | last post by:
Hi, DB2 Version 7.1 FP11 on Windows XP I have a text file containing SQL. The text file was created using db2look. CONNECT TO MYDB user db2admin using xxxxxx;
14
by: Niron kag | last post by:
Hello ! With c# , I want to write to a text file in a specific font and color. Any ideas ? Thanks...
1
by: sachin10 | last post by:
hi i m sachin, i m new to VB programming.i face some problem regarding the sorting of text file contents using arrays.text file have data in the format as below seq...
2
by: Sheldon | last post by:
I'm using DoCmd.TransferText acImportDelim... to import a tab-delimited ..txt file using an Import Specification file and that works fine. The problem is that a few records could have...
6
Atran
by: Atran | last post by:
Hello: In this article: You will learn to Write or Read A Text File. Let's Begin: First Create a new project (ConsoleApp or WinApp). And Make sure your program uses these namespaces: using...
3
by: cmdolcet69 | last post by:
How do i parse a text file with data value in it? I have a series of values that are sepereated by commas. the file holds around 3700 values and all these values need to be parsed out and put into...
4
by: mvvdsteen | last post by:
Hello all, I'm quite new to c++. I made a small program that will help me analyse wind tunnel data. But now I want this program to write to a text file. This works just fine, except it discards...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.