LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Read/edit/write from/to files

Hello everbody,
I know C++, so below is a code I wrote that opens/reads a file and looks for
certain character and writes into another file all X and Y coordinates of a
pecific character.

I would like to build a matrix using VB:
I need help on how to open and read a text file(read every character in
file), then create a matrix and insert everyone of those characters into a
table (matrix) in VB.

Could anybody help with this.
int main()
{
FILE *infile, *InkLocsFile;
char line[MAXLINE]={0}; //wmapBitLoc[rows][cols]
int n=0,i=0,j=0, flag=0, cl=0,Ink=0, rw = -1;

infile = fopen("wmap.txt", "r"); //open fail file for reading and writing
if (infile == NULL)
{
printf("\nError (Error opening wmap file): %s file failed to
open.\n",infile);
exit(0);
}//end if


InkLocsFile = fopen("InkLocsFile.txt", "w");
fprintf (InkLocsFile, "RowLoc ColLoc \n");
fprintf (InkLocsFile, "----- ------ \n");

while ( (fgets (line,sizeof(line),infile) != NULL))
{
rw +=1;
// if (strstr(line))
// {
for (n=0; n<MAXLINE; n++)
{
if (line[n] == 48)
{
cl =n;
fprintf (InkLocsFile, "%2d %10d \n",rw, cl);
}//end if (line[n] == 0)

}// end for

// }//end if strstr()

}//end While
fclose (infile);
fclose (InkLocsFile);
return 0;
}//end main()
C++ code:



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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
Saving Excel files to Read/Write only folders vteventrider Excel Discussion (Misc queries) 1 September 5th 07 08:31 PM
I have a read only xl file, I need it to be read and write drama queen Excel Discussion (Misc queries) 3 July 1st 06 12:25 AM
Sharing read-write Excel 2003 files ttt8262 Excel Discussion (Misc queries) 0 April 1st 06 09:39 PM
How can a file be converted from Read-Only to Read/Write Jim in Apopka Excel Discussion (Misc queries) 2 November 19th 05 04:59 PM
Read/Write data to/from text files from a spreadsheet. lothario[_37_] Excel Programming 8 November 2nd 03 03:10 PM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"