I am trying to calculate the height and width of a char array? The char is like an Ascii art of a card. And what I am trying to do is calculate how long the width is before the '\n'(newline), and how long the height is till the null terminator. Thanks.
baltair
0
Newbie Poster
Recommended Answers
Jump to Postfor(int i=0; i<size; ++i) { if(text[i] == '\n') height += 1; }
If there are \n characters in your text array, this loop will count them. Is height initialized properly?
for(int i=0; i < size; ++i) if(text[i] != '\n') width += 1;
All this …
All 5 Replies
arshad115
-3
Junior Poster in Training
baltair
0
Newbie Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
arshad115
-3
Junior Poster in Training
WaltP
commented:
We don;t solve problems for people -- we point out how to solve them for themselves.
-3
baltair
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.