473,663 Members | 2,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to read a file randomly

1 New Member
hi.......
i want a code which give me random excess to a file .......means let us say a file is there and i want to read data between 2 specific line and i have the line no. of both the line........... ..how could i do that ............... ...
thanks
Aug 23 '06 #1
1 1740
D_C
293 Contributor
Load each line of the file into an array/vector, depending on whether the number of lines is constant, and use indexes.
Aug 23 '06 #2

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

Similar topics

8
2341
by: nephish | last post by:
Hey there. i want to set a variable to represent the last line of a text file how do i do that? or even better, how do i create a list of the lines of a text file?
3
3243
by: Jeremy | last post by:
I have a most aggravating problem. I don't understand what is causing readlines() not to read all the lines in the file. I have the following syntax: # some initial stuff XS = xsdir(Datapath + '/xsdir', options.debug) # some more stuff
13
2312
by: Don Kim | last post by:
I'm writing a program to read 2,000,000 floating point numbers off a text file, to compute the sum, mean, and median. This is a direct example of Stroustrup's paper. But the program will not display the total number of elements beyone 23,272: #include<vector> #include<fstream> #include<iostream> #include<algorithm>
2
2691
by: CJ | last post by:
Newbie here. Trying to tackle following: Read text file containing list of files delimited by end of line chars. I need to somehow write a loop that filters out each of the lines of text within the text file as a filename to which I can then apply a number of functions.
1
3257
by: Benny Ng | last post by:
Hi,All, Export Method: ------------------------------------------------------------------------- strFileNameExport = "Results" Response.Clear() Response.Buffer = True Response.ContentType ="application/vnd.ms-excel" 'application/msword
3
1495
by: brian | last post by:
Hello, Can someone tell me how I can randomly assign a file to a variable from a directory. Example: Dim File as string I need to search through 'C:/Comics/' and have the program randomly pick a file from that path and assign it
7
1910
by: mavrick_101 | last post by:
Hi, I am trying to read a file through classic ASP. The file is located on a file server, seperate from the webserver. This is the path I'm trying to read the file from \\FILESERVER\MYFOLDER\myfile.txt How can I accomplish this task?
24
6134
by: rudranee | last post by:
hi there, can anyone tell me how to lines from a file which are odd numbered i.e. 1st,3rd,5th...lines. i tried incrementing file pointer by 2 (fp=fp+2) but it does'nt work Can someone give me the code please.
2
2495
by: TPK | last post by:
I have an HTML document with Javascript where I have a portion of the page contents, a series of questions, being pulled from a XML file. When the page dynamically builds all the questions and selection choices are listed top down in the order they appear in the XML file. Here is an example of the XML formatting: <question type="single_answer">The text of a question. <answer correct="no">A. Answer One <user_feedback>Incorrect...
1
1535
by: irfath | last post by:
Write an interactive program that reads three (3) lists of numbers, which are stored in three separate files, and creates one (1) sorted list. Each file should contain not more than 15 numbers. First, you need to create a program that randomly chooses a size (<= 15 numbers) for the list1 and then randomly generates a list of numbers and store them in the file1. Repeat this procedure to select the other two lists (list2 and list3) and stores them...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
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
8634
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5657
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
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
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 we have to send another system
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
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.