473,473 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to display a string in many lines, each lines have a specified length

Hi you!!

I am programming a part of my application and I met a trouble in
display test.

I used fgets to read each line in a text file and display all lines on
the screen. But the size of the window are too small to display all the
line(208,320), So can I ask you how to divide split a string(a line in
file) into many lines and dis play them on the screen so that all the
characters of the string would be displayed fully.
I am looking forward to your support!!

Can you contact me via my email: th*****@dsp.com.vn

Sincerely and thanks,

Thanh Thuy

Dec 6 '05 #1
1 1558
th*****@dsp.com.vn wrote:
Hi you!!

I am programming a part of my application and I met a trouble in
display test.

I used fgets to read each line in a text file and display all lines on
the screen. But the size of the window are too small to display all the
line(208,320), So can I ask you how to divide split a string(a line in
file) into many lines and dis play them on the screen so that all the
characters of the string would be displayed fully.
I assume you are using some kind of "console" window for your
application. A console usually wraps the text if it extends past the
end of the line.

However, you may get a substring of the length you want:

# include <string>
# include <iostream>

int main()
{
std::string s("a long long long line");
std::cout << s.substr(0, 10); // prints "a long lon"
}

And you can "pause" by adding a

std::cin.get();

whenever X lines are printed.
Can you contact me via my email: th*****@dsp.com.vn


No. Post here, read here.
Jonathan

Dec 6 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
16
by: Khuong Dinh Pham | last post by:
I have the contents of an image of type std::string. How can I make a CxImage object with this type. The parameters to CxImage is: CxImage(byte* data, DWORD size) Thx in advance
9
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but...
15
by: Daren | last post by:
Hi, I need to be able to split large string variables into an array of lines, each line can be no longer than 70 chars. The string variables are text, so I would additionally like the lines...
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
13
by: Freaker85 | last post by:
Hello, I am new at programming in C and I am searching a manner to parse a string into an integer. I know how to do it in Java, but that doesn't work in C ;o) I searched the internet but I...
2
by: AZRebelCowgirl73 | last post by:
Crazy as this sounds this program is actually working! I know I know it is amazing I got one to run. The only problem I am having is I want it to say for output line (1,2 3 etc.) has a length...
2
by: dmk | last post by:
Hi Again, I am reading a document into a page and then displaying it as source code (this is for an assignment.) I feel that the output that I am getting is a little hard to read, and want to...
2
Claus Mygind
by: Claus Mygind | last post by:
I have an array of objects (a hash table). My section of code, the "for in" loop (lines 18 to 41) does not execute at full speed. But if I put in an alert box (line 13) to stop program execution...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.