random « Development « C File Q&A

Home
C File Q&A
1.array
2.binary
3.delete
4.Development
5.directory
6.fgets
7.fopen
8.fprintf
9.fscanf
10.fwrite
11.header
12.include
13.input
14.LINE
15.linux
16.open
17.output
18.pointer
19.read
20.size
21.string
22.struct
23.Text
24.windows
25.write
C File Q&A » Development » random 

1. Efficient random access within a file? [C]    stackoverflow.com

I have a text file I use to hold an index of files and words (with their frequencies) that appear in them. I need to read the file into memory and ...

2. How to edit a random position of a file with fstream apis?    bytes.com

James Fang wrote: I need to edit a random position of a file, for e.g, the 500th byte. To keep portability, I would like to use standard C++ instead of os apis. Could you help on this? What exactly do you need help with? Open the file for read+write. Position the stream at 500. Write the new byte. Close the stream. ...

3. Random index structure based file managment in C    cboard.cprogramming.com

1) Don't be sprouting threads all over the place... 2) Don't be demanding code. I gave you a good example as a starting point... now it's up to you to apply brain to task and *figure this out on your own*, with a little help when you get stuck. We are here to help people debug their code, offer occasional suggestions ...

4. Random Access Files...ugh.    cboard.cprogramming.com

Random Access Files...ugh. This is a program I wrote a few weeks ago for an online class, but it won't execute properly, and I've been trying to fix it for awhile now. The compiler doesn't give any build errors, but it will allow the user to create a tool record, but then a few problem come up... I want to try ...

5. Random Reads to file...    cboard.cprogramming.com

I have the following code to randomly seek inside a file and read (or write) that location. When I try to execute it for a 32 mb (1<<25) file using: ./a.out /dev/sda3 25, it gives the error: Error in read : Invalid argument. Whats wrong and how do I fix it? Code: #define _GNU_SOURCE #include #include #include #include ...

6. File Copying - Random chars at the end    cboard.cprogramming.com

7. Random access files and structures    cboard.cprogramming.com

Random access files and structures Right now I'm trying to read in a buncho f data from the text file "Top_Movies.txt" and putting the data into a structure. This is what I have so far. Now I know it isn't goign to work so I'm not even going to bother trying to compile it...but am I even close? I think I ...

8. Creating a file with random numbers question??    cboard.cprogramming.com

Hey guys. I need some help..bad. I have to write a program that creates a file of randomly distributed numbers. I have the functions figured out and some of the main(). Could you guys take a look at it and just try to steer me in the right direction. I'm just confused on how to get a filename from user, and ...

9. Random Sentence From A File    cboard.cprogramming.com

#include #include #include #include #include #include void main(void) { char **line,c; int i=0,j=0,*slen,a,k; FILE *myfile; myfile = fopen("mycookies.txt","r"); if (myfile == NULL) { printg("Warning!Cannot open file."); exit -1; } while ( !feof(myfile) ) { fscanf(myfile,"%c",c); while(c!='\n') { line[i][j]=c; fscanf(myfile,"%c",&c); j++; } slen[i]=j; i++ } a=randomize(i); for(k=0;k

10. Counting number from a random file    cboard.cprogramming.com

Hi!! I am a newbie at C programming, and I need help wih my program... I am suppose to write a C program that opens up the generated file and produces a report that looks like: Number of records : you determine the value and print it here Maximum Value : you determine the value and print it here Minimum Value ...

11. Random generation of filenames and files    cboard.cprogramming.com

12. print Random Files    cboard.cprogramming.com

Code: #include /*********** Data ***********/ typedef struct { int id; float gpa; }data; /*********** The functions ***********/ void read(data*); void print(FILE*); /*********** Main ***********/ int main(){ data R; FILE *f; int i; if((f=fopen("f.dat","w"))==NULL) printf("sorry i can not open the file\n"); else{ fseek(f,sizeof(data),SEEK_SET); for(i=1;i<=3;i++){ read(&R); fseek(f,sizeof(data)*(i-1),SEEK_SET); fwrite(&R,sizeof(data),1,f); } } print(f); return 0; } /*********** Read ***********/ void read(data *R){ printf("Enter the id ...

13. Random File Issues    cboard.cprogramming.com

When I tried your code, it produced the same output. It worked the first time. So I tried to input new data and it produced the same semi-gibberish output the second time around. Don't worry about that, the fseek seems to work ok. What I'm now having trouble with is the reorder field of the structure. It keeps changing the integer ...

14. Random Access Files    cboard.cprogramming.com

I'm in the process of creating a program that maintains a staff details file. I've got all the code that creates a random access file, and I can add entries and sort them in the right order within the file. I have now hit a brick wall when it comes to modifying an existing record within the file. The file contains ...

15. Random Reads to file...    forums.devshed.com

I have the following code to randomly seek inside a file and read (or write) that location. When I try to execute it for a 32 mb (1<<25) file using: ./a.out /dev/sda3 25, it gives the error: Error in read : Invalid argument. Whats wrong and how do I fix it? Code: #define _GNU_SOURCE #include #include #include #include ...

16. How to select items from a file randomly?    forums.devshed.com

Hi guys, I've searched on these forums for info that I hoped would help me to 'get it' in terms of what it is I'm trying to do, but so far I've just got more and more bogged down with confusion, so I hope you can help me. I'm writing a program in C (which I'm fairly new to) where I ...

17. random file access using C    forums.devshed.com

Just a quicky, Is it possible to do random access file reads using C [not C++]. I would like to say somthing that would conform to :- get me the characters from file Ptr, starting at possition X, and ending att possition Y. I know that it probally seems a tedious thing to ask but searchin both google and here have ...

18. Random Files    daniweb.com

void addReserve() { char uoption; int option=0; int i=0; int count = 1; int res_num; FILE *reserver; srand(time(NULL)); if((reserver=fopen("reservations.txt", "rb+"))==NULL) { printf("\nFile could not be opened, file is now be created"); if((reserver=fopen("reservations.txt", "wb+"))==NULL) { printf("Error in creatiing/opening file"); _getch(); } else { for (; i < 100; i++) { fwrite( §ion, sizeof( ADMISSION_DATA ), 1, reserver ); printf("\nRecord # %d", count); ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.