473,791 Members | 2,947 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reading a text file into a 2d array problem

6 New Member
Hello.
I am trying to read a text file that contains

1
2
3

it just looks like that. I was able to read it and assign each number to a matrix element (or array element). It was reading it all fine and I was trying to change the elements to int variables a,b,c so that I could say matrix[i][j] = {a,b,c};

At some point during tweaking all the matrix elements became 0 and I have lost myself.
Look at my code please.
I realise this is not the best programming way of writing code but I'm a scientist and I'd rather do it the way I have. If its too annoying to read then please suggest something else.



My code below.

Expand|Select|Wrap|Line Numbers
  1. #include<sstream>
  2. #include <iostream>
  3. #include<fstream>
  4. #include <string>
  5. #include <stdlib.h>
  6.  
  7. using namespace std;
  8. int i,j;
  9. int a,b,c;
  10.  
  11.  
  12. int main ()
  13. {
  14.  // getting the data from a text file
  15.         string str;
  16.   ifstream myfile("C:\\brooks\\C++ examples\\Data set 1.txt", ios::in);
  17.   // above opens the file
  18.   if (myfile.is_open()) // if open do the following
  19.   {
  20.     while (! myfile.eof() ) // while loop to do the below until the end of the file
  21.         {
  22.                   getline(myfile, str);
  23.                   cout<<str<<endl;
  24.           // matrix defining
  25.                   int matrix[3][1]={i,j};
  26.           for (i=0; i<3; i++)
  27.           for (j=0; j<1; j++)
  28.  
  29.  
  30.           myfile >> matrix[0][0]  >>  matrix[1][0] >>  matrix[2][0] >> ws;
  31.  
  32.           matrix[0][0] = a;
  33.           matrix[1][0] = b;
  34.           matrix[2][0] = c;
  35.  
  36.          int matrix[i][j] = {a, b, c};         // error here C2057 & C2087, due to the a=b=c=0 at the moment
  37.  
  38. // assigned the 3 numbers to the matrix elements
  39. cout << matrix[0][0] << " " << matrix[1][0] << " " << matrix[2][0] << endl;
  40.  
  41.         //cout << matrix[i][j];
  42.  
  43. // attempted string to int conversion
  44. //p = atof(line );
  45.  
  46.  
  47.         }
  48.  
  49. myfile.close();
  50.   }
  51.  
  52.  
  53.  else cout << "Unable to open file";
  54.  
  55.   return 0;
  56. }
thanks
Ben
May 25 '07 #1
10 7514
Ganon11
3,652 Recognized Expert Specialist
Well, you never initialize a, b, and c in your program (which in itself is not a good idea), but then, after you input into matrix[0][0], matrix[0][1], and matrix[0][2], you assign each of these three slots to a, b, and c, respectively. Not only does this override whatever information you pulled from the file, but it fills the array with garbage values.

What exactly are you trying to do? I imagine there's a much simpler, cleaner option than all this.
May 25 '07 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
I think you are making this too hard.

First, there really aren't 2D arrays in C++. There are only one-dimensional arrays. That is:
Expand|Select|Wrap|Line Numbers
  1. int matrix[6] = {1,2,3,4,5,6};
  2.  
is laid out in memory as 1 2 3 4 5 6.

Whereas this array:
Expand|Select|Wrap|Line Numbers
  1. int arr[3][2] = {1,2,3,4,5,6};
  2.  
is laid out in memory as 1 2 3 4 5 6.

Kinda the same, right?

The "dimensions " are really descriptions of the elements. In the first example there are 6 elements in the matrix array and each element is an int. In the second example, there are 3 elements in the array and each element is an array of 2 int.

You use the "dimensions " as a convenience for doing math.

However, since all arrays are laid out serially in memory, I suggest you write your 2D array out as individual integers starting with &arr[0][0]. For example, an int arr[10][4] has 40 integers. Start with &arr[0][0] and write out 40 ints.

On the restore, start at &arr[0][0] and read 40 ints.

Once that's done you can use your array as a 2D array as you normally would.
May 25 '07 #3
bodowpin
6 New Member
Well, you never initialize a, b, and c in your program (which in itself is not a good idea), but then, after you input into matrix[0][0], matrix[0][1], and matrix[0][2], you assign each of these three slots to a, b, and c, respectively. Not only does this override whatever information you pulled from the file, but it fills the array with garbage values.

What exactly are you trying to do? I imagine there's a much simpler, cleaner option than all this.

I'm trying to read values from a text file and make a "matrix". As c++ doesnt understand what a matrix is without a "matrix header file" i'm using arrays. I wanted to be able to call matrix[i][j] and the output should be 1,2,3 which was read from the text file.
This matrix will be used in matrix equation algebra. The matrix represents a 3d point and I'm trying to translate and rotate this 3d point to match up with another 3d point. I have all the maths equations its just trying to implement them in c++ that's the dificulty. I'm at home and can't tell you exactly what maths will be used on the matrix. Does that answer your question?


[quote=Ganon11] after you input into matrix[0][0], matrix[0][1], and matrix[0][2], you assign each of these three slots to a, b, and c, respectively

I was trying to read the text file values into each element of the matrix, when this didnt work I thought it was due a string to int problem. I thought that by assigning matrix[0][0] to an int a it would change the string to an integer. Basically I'm unsure if reading from the text file gives me a string or because the file only contains number if it will be an int. I see now what I did is problematic but I don't see how to do what I want.

also how do initialize a,b,c? I said they were int at the beginning of the code but you mean initialize a value? I have seen people do a=b=c=0 before using them but does that then not make them 0 and I wanted them to be values from the file.
May 27 '07 #4
bodowpin
6 New Member
weaknessforcats I have made it too dificult but I really need to stick to the matrix[i][j] format. This is so I understand what I'm doing in terms of matrices or else I may get confused. I could individually assign elements like matrix[0][0] which is what I was doing but I need to be able to get an output for matrix[i][j] which should read 1,2,3 So I can use it in calculations later.

Thanks for the talk on arrays but I don't think what you suggested will help, my fault for not specifying what I wanted to do or aim to get.
May 27 '07 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
Yes, you have made it too difficult. However, at the risk of confusing you, I took your code and twiddled it to illustrate what I said:

Expand|Select|Wrap|Line Numbers
  1. #include<sstream>
  2. #include <iostream>
  3. #include<fstream>
  4. #include <string>
  5. #include <stdlib.h>
  6.  
  7. using namespace std;
  8. int main ()
  9. {
  10.     //
  11.     //The target matrix
  12.    //
  13.     int matrix[3][1];
  14.     int* input = &matrix[0][0];
  15.  // getting the data from a text file
  16.         string str;
  17.   //ifstream myfile("C:\\brooks\\C++ examples\\Data set 1.txt", ios::in);
  18.   ifstream myfile("C:\\scratch\\instructor\\Data set 1.txt", ios::in);
  19.   // above opens the file
  20.   if (myfile.is_open()) // if open do the following
  21.   {
  22.     while (! myfile.eof() ) // while loop to do the below until the end of the file
  23.         {
  24.           myfile >> *input;  //put the int in the matrix array
  25.           ++input;               //set up for the next element
  26.  
  27.         }
  28.  
  29.  
  30.   }
  31.   else
  32.   {
  33.       cout << "Unable to open file";
  34.   }
  35.  
  36.   // assigned the 3 numbers to the matrix elements
  37.   cout << matrix[0][0] << " " << matrix[1][0] << " " << matrix[2][0] << endl;
  38.  
  39.   return 0;
  40. }
  41.  
First, I declared your matrix at the beginning of main()
Second, I declared an int* to contain the address of matrix[0][0]
Third, I de-reference the the int* when I use >>
Fourth, I increment the int* after using it to set up for the next element
Fifth, At the end of main(), I display the 2D matrix and there are your integers.
May 27 '07 #6
bodowpin
6 New Member
First, I declared your matrix at the beginning of main()
Second, I declared an int* to contain the address of matrix[0][0]
Third, I de-reference the the int* when I use >>
Fourth, I increment the int* after using it to set up for the next element
Fifth, At the end of main(), I display the 2D matrix and there are your integers.[/quote]


I understand now what you meant and see how yours works and mine didn't. I do have one question though.
Why can I not output matrix[3][1] and it give me 1,2,3? Do I always have to work with individual elements of the array?

I will be doing some addition, multiplication etc and was hoping not to have to do it using individual elements. If thats the only way to do it then obviously I will, its just later I intend on taking a set of matrice's and it would get tedious doing say 10 matrices.
Thanks for the help you guys I shall press on and if I get stuck I know where to come.
May 28 '07 #7
weaknessforcats
9,208 Recognized Expert Moderator Expert
Why can I not output matrix[3][1] and it give me 1,2,3? Do I always have to work with individual elements of the array?
Your example is matrix[3][1]. That is 3 arrays with elements that are arrays of 1 int each.

So, matrix[0] is the element 0 in matrix. and matrix[0][1] is element 0 in
matrix[0].

This is identical to matrix[3]. matrix[3] is an array of 3 int.

You will work with individual elements when you work with the ints themselves.
May 28 '07 #8
bodowpin
6 New Member
Your example is matrix[3][1]. That is 3 arrays with elements that are arrays of 1 int each.

So, matrix[0] is the element 0 in matrix. and matrix[0][1] is element 0 in
matrix[0].

This is identical to matrix[3]. matrix[3] is an array of 3 int.

You will work with individual elements when you work with the ints themselves.


From what you mentioned, is it possible to have matrix[3][1] give 1,2,3 if i didn't assign 1,2 or 3 as int's.
Sorry if this is a dumb question.
May 30 '07 #9
bodowpin
6 New Member
Another question related to my code.

I have moved on and am now trying to implement an svd algirithm to my code.

My huge code is below,
#include<sstrea m>
#include <iostream>
#include<fstrea m>
#include <string>
#include <stdlib.h>
#include <math.h>
#include "nrutil.h"

using namespace std;


int main ()
{
//
// matrix a definition
//
int amatrix[3][1];
int* inputa = &amatrix[0][0];
// getting the data from a text file
string stra;
ifstream myfilea("C:\\br ooks\\C++ examples\\Data set 1.txt", ios::in);

// above opens the file
if (myfilea.is_ope n()) // if open do the following
{
while (! myfilea.eof() ) // while loop to do the below until the end of the file
{
myfilea >> *inputa; //put the int in the matrix array
++inputa; //set up for the next element

}


}
else
{
cout << "Unable to open file";
}

// assigned the 3 numbers to the matrix elements
//cout << amatrix[0][0] << " " << amatrix[1][0] << " " << amatrix[2][0] << endl;


//
//matrixb definition
//
int bmatrix[3][1];
int* inputb = &bmatrix[0][0];
// getting the data from a text file
string strb;
ifstream myfileb("C:\\br ooks\\C++ examples\\Data set 2.txt", ios::in);

// above opens the file
if (myfileb.is_ope n()) // if open do the following
{
while (! myfileb.eof() ) // while loop to do the below until the end of the file
{
myfileb >> *inputb; //put the int in the matrix array
++inputb; //set up for the next element

}


}
else
{
cout << "Unable to open file";
}

// assigned the 3 numbers to the matrix elements, this is my b matrix
//cout << bmatrix[0][0] << " " << bmatrix[1][0] << " " << bmatrix[2][0] << endl;

//matrix a is pi.
// for this example pi = p due to only using one matrix per data set.

// matrix b is p'i.
// for this example p'i=p' due to only using one matrix per data set.

// from Haung and Blostein's paper, " least squares fitting of Two 3-d point sets
// qi = pi - p, q'i = p'i - p'.


// qi matrix definition
int qmatrix[3][1];
int* inputq = &qmatrix[0][0];

// q'i matrix definition
int qamatrix[3][1];
int* inputqa = &qamatrix[0][0];

// qi = matrixa - matrixb, q'i = matrixa - matrixb.
// have to do them as seperate elements
// qi matrix below

qmatrix[0][0] = amatrix[0][0] - bmatrix[0][0];
qmatrix[1][0] = amatrix[1][0] - bmatrix[1][0];
qmatrix[2][0] = amatrix[2][0] - bmatrix[2][0];

//cout<< qmatrix[0][0] << qmatrix[1][0] <<qmatrix[2][0];

//q'i matrix below
qamatrix[0][0] = amatrix[0][0] - bmatrix[0][0];
qamatrix[1][0] = amatrix[1][0] - bmatrix[1][0];
qamatrix[2][0] = amatrix[2][0] - bmatrix[2][0];

cout<< qamatrix[0][0]<<" "<< qamatrix[1][0]<<" "<<qamatrix[2][0]<< "\n";


// H is defined by equation 11, sum of (qi q'i).
// H is a 3 by 3 matrix.

int Hmatrix[3][3];
int* inputH = &Hmatrix[0][0];

Hmatrix[0][0]= qmatrix[0][0]*qamatrix[0][0];
Hmatrix[0][1]= qmatrix[0][0]*qamatrix[1][0];
Hmatrix[0][2]= qmatrix[0][0]*qamatrix[2][0];
Hmatrix[1][0]= qmatrix[1][0]*qamatrix[0][0];
Hmatrix[1][1]= qmatrix[1][0]*qamatrix[1][0];
Hmatrix[1][2]= qmatrix[1][0]*qamatrix[2][0];
Hmatrix[2][0]= qmatrix[2][0]*qamatrix[0][0];
Hmatrix[2][1]= qmatrix[2][0]*qamatrix[1][0];
Hmatrix[2][2]= qmatrix[2][0]*qamatrix[2][0];

cout<< Hmatrix[0][0]<< " "<< Hmatrix[0][1]<<" "<< Hmatrix[0][2]<<" "<< Hmatrix[1][0]<<" "<< Hmatrix[1][1]<<" "<< Hmatrix[1][2]<<" "<< Hmatrix[2][0]<<" "<< Hmatrix[2][1]<<" "<< Hmatrix[2][2];



////////////////////////////////////////// SVD of a NxM Matrix //////////////////////////////////

int n;
int m;
float **v;
float w[3]; // for our case n is 3.
float **a;

void svdcmp(**a, m,n, w[3], **v);
/*Given a matrix a[1..m][1..n], this routine computes its singular value decomposition, A =
U•W•V T. Thematrix U replaces a on output. The diagonal matrix of singular values W is output
as a vector w[1..n]. Thematrix V (not the transpose V T ) is output as v[1..n][1..n].*/
{
Hmatrix[3][3] = a[m][n]; // i added this to make Hmatrix be the same as below
float pythag(float a,float b);
int flag,i,its,j,jj ,k,l,nm;
float anorm,c,f,g,h,s ,scale,x,y,z,*r v1;
rv1=vector(1,n) ;
g=scale=anorm=0 .0; //Householder reduction to bidiagonal form.
for (i=1;i<=n;i++) {
l=i+1;
rv1[i]=scale*g;
g=s=scale=0.0;
if (i <= m) {
for (k=i;k<=m;k++) scale += fabs(a[k][i]);
if (scale) {
for (k=i;k<=m;k++) {
a[k][i] /= scale;
s += a[k][i]*a[k][i];
}
f=a[i][i];
g = -SIGN(sqrt(s),f) ;
h=f*g-s;
a[i][i]=f-g;
for (j=l;j<=n;j++) {
for (s=0.0,k=i;k<=m ;k++) s += a[k][i]*a[k][j];
f=s/h;
for (k=i;k<=m;k++) a[k][j] += f*a[k][i];
}
for (k=i;k<=m;k++) a[k][i] *= scale;
}
}
w[i]=scale *g;
g=s=scale=0.0;
if (i <= m && i != n) {
for (k=l;k<=n;k++) scale += fabs(a[i][k]);
if (scale) {
for (k=l;k<=n;k++) {
a[i][k] /= scale;
s += a[i][k]*a[i][k];
}
f=a[i][l];
g = -SIGN(sqrt(s),f) ;
h=f*g-s;
a[i][l]=f-g;
for (k=l;k<=n;k++) rv1[k]=a[i][k]/h;
for (j=l;j<=m;j++) {
for (s=0.0,k=l;k<=n ;k++) s += a[j][k]*a[i][k];
for (k=l;k<=n;k++) a[j][k] += s*rv1[k];
}
for (k=l;k<=n;k++) a[i][k] *= scale;
}
}
anorm=FMAX(anor m,(fabs(w[i])+fabs(rv1[i])));
}
for (i=n;i>=1;i--) { //Accumulation of right-hand transformations .
if (i < n) {
if (g) {
for (j=l;j<=n;j++) //Double division to avoid possible underflow.
v[j][i]=(a[i][j]/a[i][l])/g;
for (j=l;j<=n;j++) {
for (s=0.0,k=l;k<=n ;k++) s += a[i][k]*v[k][j];
for (k=l;k<=n;k++) v[k][j] += s*v[k][i];
}
}
for (j=l;j<=n;j++) v[i][j]=v[j][i]=0.0;
}
v[i][i]=1.0;
g=rv1[i];
l=i;
}
for (i=IMIN(m,n);i> =1;i--) { //Accumulation of left-hand transformations .
l=i+1;
g=w[i];
for (j=l;j<=n;j++) a[i][j]=0.0;
if (g) {
g=1.0/g;
for (j=l;j<=n;j++) {
for (s=0.0,k=l;k<=m ;k++) s += a[k][i]*a[k][j];
f=(s/a[i][i])*g;
for (k=i;k<=m;k++) a[k][j] += f*a[k][i];
}
for (j=i;j<=m;j++) a[j][i] *= g;
} else for (j=i;j<=m;j++) a[j][i]=0.0;
++a[i][i];
}
for (k=n;k>=1;k--) { //Diagonalization of the bidiagonal form: Loop over singular values,
for (its=1;its<=30; its++) { //and over allowed iterations.
flag=1;
for (l=k;l>=1;l--) { //Test for splitting.
nm=l-1; //Note that rv1[1] is always zero.*/
if ((float)(fabs(r v1[l])+anorm) == anorm) {
flag=0;
break;
}
if ((float)(fabs(w[nm])+anorm) == anorm) break;
}
if (flag) {
c=0.0; //Cancellation of rv1[l], if l > 1.
s=1.0;
for (i=l;i<=k;i++) {
f=s*rv1[i];
rv1[i]=c*rv1[i];
if ((float)(fabs(f )+anorm) == anorm) break;
g=w[i];
h=pythag(f,g);
w[i]=h;
h=1.0/h;
c=g*h;
s = -f*h;
for (j=1;j<=m;j++) {
y=a[j][nm];
z=a[j][i];
a[j][nm]=y*c+z*s;
a[j][i]=z*c-y*s;
}
}
}
z=w[k];
if (l == k) { //Convergence.
if (z < 0.0) { //Singular value is made nonnegative.
w[k] = -z;
for (j=1;j<=n;j++) v[j][k] = -v[j][k];
}
break;
}
if (its == 30) nrerror("no convergence in 30 svdcmp iterations");
x=w[l]; //Shift from bottom 2-by-2 minor.
nm=k-1;
y=w[nm];
g=rv1[nm];
h=rv1[k];
f=((y-z)*(y+z)+(g-h)*(g+h))/(2.0*h*y);
g=pythag(f,1.0) ;
f=((x-z)*(x+z)+h*((y/(f+SIGN(g,f)))-h))/x;
c=s=1.0; //Next QR transformation:
for (j=l;j<=nm;j++) {
i=j+1;
g=rv1[i];
y=w[i];
h=s*g;
g=c*g;
z=pythag(f,h);
rv1[j]=z;
c=f/z;
s=h/z;
f=x*c+g*s;
g = g*c-x*s;
h=y*s;
y *= c;
for (jj=1;jj<=n;jj+ +) {
x=v[jj][j];
z=v[jj][i];
v[jj][j]=x*c+z*s;
v[jj][i]=z*c-x*s;
}
z=pythag(f,h);
w[j]=z; //Rotation can be arbitrary if z = 0.
if (z) {
z=1.0/z;
c=f*z;
s=h*z;
}
f=c*g+s*y;
x=c*y-s*g;
for (jj=1;jj<=m;jj+ +) {
y=a[jj][j];
z=a[jj][i];
a[jj][j]=y*c+z*s;
a[jj][i]=z*c-y*s;
}
}
rv1[l]=0.0;
rv1[k]=f;
w[k]=x;
}
}
free_vector(rv1 ,1,n);
}
float pythag(float a, float b)
//Computes (a2 + b2)1/2 without destructive underflow or overflow.
{
float absa,absb;
absa=fabs(a);
absb=fabs(b);
if (absa > absb) return absa*sqrt(1.0+S QR(absb/absa));
else return (absb == 0.0 ? 0.0 : absb*sqrt(1.0+S QR(absa/absb)));
}

////////////////////////////////////////////////////////////////////////////////////////////////

return 0;
}


I get errors in the svd part of the code which I'm trying to iron out.

c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (137) : error C2182: 'svdcmp' : illegal use of type 'void'
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (137) : error C2078: too many initializers
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (137) : warning C4244: 'initializing' : conversion from 'float' to 'int', possible loss of data
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (142) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (215) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (246) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (271) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (298) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (320) : error C2601: 'pythag' : local function definitions are illegal
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (13): this line contains a '{' which has not yet been matched
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (324) : warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data
c:\brooks\visua l studios 8 vc bin\myfirstprog ram\task 1 rotation and translation\tas k 1 rotation and translation\tas k 1 rotation and translation.cpp (325) : warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data

My issue is trying to make my Hmatrix be the a[n][m] matrix. One of the errors I was getting said that the Hmatrix was undefined, this occured when I put it in the svdcmp function but clearly I have defined it above.

So my question is how do I use my matrix in that svd algorithm. The algorithm was taken from numeric recipes in c, written by Press amognst others.

Thanks
May 30 '07 #10

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

Similar topics

2
2497
by: Sabin Finateanu | last post by:
Hi I'm having problem reading a file from my program and I think it's from a procedure I'm using but I don't see where I'm going wrong. Here is the code: public bool AllowUsage() { OperatingSystem os = Environment.OSVersion; AppDomain ad = Thread.GetDomain();
10
1726
by: T Cordon | last post by:
I am using a StreamReader to read text from an HTML file and display it as part of a page in a Label Control. Buy it is not displaying characters as: ñ, ó, ú, etc. Please Help. Thanks
7
6063
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should populate a series of structures of specified variable composition. I have the structures created OK, but actually reading the files is giving me an error. Can I ask a simple question to start with: I'm trying to read the file using the...
10
2808
by: nuke1872 | last post by:
Hello guys, I have a file names network.txt which contains a matrix. I want to read this matrix as store it as an array. I am new to stuff like these...can anybody help me out !! Thanks nuke
1
1547
by: bbepristis | last post by:
Hey all I have a wired issue I have a csv file with , seperated values I have some code to read the file and put the record into an array then into textboxes. the problem is it seems to read everyother line of the file not everyline at first I thought it might be the code then the csv file The csv is a mysql generated via webmin however I cant seem to find the problem anywhere so please advise. -- CODE-- Public Sub csv_conn() 'Opens...
3
1806
by: lizii | last post by:
i have a file - which on each line has some data i need to fill into a box - now although reading in the data is simple enough and putting it in the correct box will be no problem, as i can just read a lilne then put into the corresponding box...it just seems like a task i should be able to complete in a few lines...rather than quite a few commands. for example what i do at the moment is: read a line place into first text box
6
5274
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
2
1748
by: GeoUK | last post by:
Hi All, New member here with a bit of problem. I have read the FAQ's and searched text books but still cannot solve the problem that I have. As part of a course I am doing at University I had to write a program in C++ that would allow the user to enter student information (matriculation number, name, status and mark), which was then stored in an array. They could then search it or list it. Everything was woking (and still is) up to here....
21
3069
by: Stephen.Schoenberger | last post by:
Hello, My C is a bit rusty (.NET programmer normally but need to do this in C) and I need to read in a text file that is setup as a table. The general form of the file is 00000000 USNIST00Z 00000000_00 0 000 000 000 0000 000 I need to read the file line by line and eventually parse out each piece of the file and store in arrays that correspond to the specific
1
4743
by: stoogots2 | last post by:
I have written a Windows App in C# that needs to read a text file over the network, starting from the end of the file and reading backwards toward the beginning (looking for the last occurrence of a couple of strings in one line of text). I do not want to read the entire file, as it is very large, on a highly utilized server, and is updated with hundreds of lines of text every second. So since I am reading backwards, I do a seek, then read,...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.