is random access possible on struct records in C language?
Sushma21 0 Newbie Poster
Recommended Answers
Jump to PostI guess, you are looking for Random Access IO. Take a look at http://c-faq.com/~scs/cclass/int/sx2i.html.
Jump to Postwhat do u mean by that ?
If u want to randomly access some struct records u can make an array of that struct and proceed........
Jump to Postya...i tried doing that....i accepted array of records in 1 program and tried to access it randomly in other program by opening the file in read mode and using fseek and fread functions....but it is showing some garbage values....so i have a doubt if we can acess struct records randomly …
Jump to Postthis is the program where i input struct records...
#include<stdio.h> #include<conio.h> struct Product {
end quote.
post your program properly.
Jump to PostOpen/Create a data file using binary mode. c file io
FILE *fp; fp=fopen("c:\\test.bin", "wb"); char x[10]="ABCDEFGHIJ"; fwrite(x, sizeof(x[0]), sizeof(x)/sizeof(x[0]), fp);
Use,
…int main(){ ... return 0; }
All 22 Replies
kvprajapati 1,826 Posting Genius Team Colleague
dkalita 110 Posting Pro in Training
Sushma21 0 Newbie Poster
dkalita 110 Posting Pro in Training
Sushma21 0 Newbie Poster
dkalita 110 Posting Pro in Training
Sushma21 0 Newbie Poster
Sushma21 0 Newbie Poster
dkalita 110 Posting Pro in Training
Sushma21 0 Newbie Poster
dkalita 110 Posting Pro in Training
kvprajapati 1,826 Posting Genius Team Colleague
Sushma21 0 Newbie Poster
dkalita 110 Posting Pro in Training
Sushma21 0 Newbie Poster
dkalita 110 Posting Pro in Training
Sushma21 0 Newbie Poster
dkalita 110 Posting Pro in Training
Sushma21 0 Newbie Poster
dkalita 110 Posting Pro in Training
Sushma21 0 Newbie Poster
dkalita 110 Posting Pro in Training
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.