Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

skipping some characters in a file when printing it out in c++

sonixzsonixz Member Posts: 4
hi, i am rather new to c++. hope that someone can help me with my problem:

below is the contents of a file:


rows = 2;
cols = 2;

3 2
4 4



how should i implement the function such that after reading from the file, i will only print the matrix

3 2
4 4

and ignore the characters '' and '', as well as assign the rows and columns of my matrix to be 2? (assuming that i do not know the exact size of my matrix array in the beginning)

Comments

  • ninchagoraninchagora Member Posts: 82
    : hi, i am rather new to c++. hope that someone can help me with my problem:
    :
    : below is the contents of a file:
    :
    :
    : rows = 2;
    : cols = 2;
    :
    : 3 2
    : 4 4
    :
    :
    :
    : how should i implement the function such that after reading from the file, i will only print the matrix
    :
    : 3 2
    : 4 4
    :
    : and ignore the characters '' and '', as well as assign the rows and columns of my matrix to be 2? (assuming that i do not know the exact size of my matrix array in the beginning)
    :
    If your file is in such format you should read line by line (or word by word) from the file into a line buffer, and then parse the buffer in order to recognize tags, keywords or numbers.

Sign In or Register to comment.