473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need help with structures and files

my problem , Its some
thing like there is a file (text file) which contains the details of
the system ,like the its unique serial no which is homid and etc.
This code is working only for fetching the stating data .

#include <stdio.h>
#include <string.h>
#include <unistd.h>

struct hom_id{
char nod_de[20];
char hom_id[20];
char hom_type[20];
char hom_pid[20];
};

#define LENTH 4
int main ()

{
FILE *fp;
char buff[200];
int ret;
int read_size;
struct hom_id arr[LENTH];
int i=0;
char* poc_id = "0086";

fp = fopen("momtext.txt","r");
if ( fp == NULL )
{

printf("error");
}
sscanf ( buff , " %s %s %s %s ", &arr[i].nod_de ,
&arr[i].hom_id ,&arr[i].hom_type,&arr[i].hom_pid );

fgets ( buff, 100,fp);

printf("the hom id\t %s \t %s \t %s \t %s \n ",arr[i].nod_de,
arr[i].hom_id, arr[i].hom_type, arr[i].hom_pid );
//}

}

->I am faceing one error for this 0086 , I am getting radix error.
-Can you tell me how to moove in side a file , I need it because
the text file from which I have to fetch data is like this --

00810000 00814945 00c9 0000d005
00810000 00814946 00c9 0000d006
00810000 00814947 00c9 0000d007
00810000 00814948 00c9 0000d008
00810000 00814949 00c9 0000d009
00810000 0081494a 00c9 0000d00a
00810000 0081494b 00c9 0000d00b
00810000 00814960 00c9 0000d00c
00810000 00814961 00c9 0000d00d
00810000 00814962 00c9 0000d00e
00810000 00814963 00c9 0000d00f
00810000 00814964 00c9 0000d010
00810000 00814965 00c9 0000d011
00810000 00814966 00c9 0000d012
00810000 00814967 00c9 0000d013
00810000 00814968 00c9 0000d014
00810000 00814969 00c9 0000d015
00810000 0081496a 00c9 0000d016
00810000 0081496b 00c9 0000d017
00810000 00815000 0044 ffffffff
00810000 00815002 0044 ffffffff
00810000 00815080 0044 ffffffff
00810000 008150c0 0044 ffffffff
00810000 008150c2 0044 ffffffff
00810000 00815180 0044 ffffffff
00810000 008151e0 0044 ffffffff
00810000 008151e1 0044 ffffffff
00810000 00815280 0044 ffffffff

-I have to write a function which will take this 008151e1 as argument
(which is second column in above).
-. So for that i have to search the pattern and copy the lines which
contains the uniqe id 008151e1 to a structure .
-how can I moove inside a file so that I can searech the pattern.
->waht data type i should use to store 008151e1 this type of variable.
-.plz help me .
So I need this data in my progaram and I need only the 2nd column which
is unique for each row.
->I need to define a structure for this so that i can use the value in
my program .
->i need only the rows which contain the hom id which i have passed in
as argument.
-Plz tell me how to fetch data from file using structures?
Aug 10 '06 #1
1 1209
sk*******@gmail.com schrieb:
<snip>

Please do not repost your problem without mentioning that you
did so. This is not some forum where more or less rapid reposting
may yield more results.
Look elsethread for replies.

-Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Aug 10 '06 #2

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

Similar topics

52
by: entropy123 | last post by:
Hey all, I'm working with some legacy C code and I would like to compile it as a CPP file. I get the following error message: driver.cpp:87: cannot convert `void *' to `GenericStruct *' in...
7
by: moondaddy | last post by:
I want to create a public enum that can be used throughout a project. I created an enum like this in a module: Public Enum ParentType Project = 0 Stage = 1 VIP = 2 Func = 3 Equipment = 4...
4
by: robinsand | last post by:
My apologies to those of you who are more advanced Visual C++ .NET programmers, but I am working on a project for an MBA course that is condensed into an eight-week schedule, and I need help...
3
by: knightsmastergeneral | last post by:
Hi, I'm currently working on getting junit and junireport to take some java files, convert it to xml and then display error messages / success rates etc in html which is one of the features of...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
10
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I...
4
by: sofeng | last post by:
The following link shows a chart I created about passing structures among functions. Would you review it and tell me if it requires any corrections? ...
7
by: elgiei | last post by:
Good morning at all, i have to implement a server,that every n-seconds (eg. 10sec) sends to other clients,which files and directory has been deleted or modified. i build a n-tree, for each...
1
by: xz | last post by:
I am programming some c++ codes to be called within Matlab. If there is only one c++ file, life is simple. You simply mex the cpp file ( with mexFunction(...) )and call the function within...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.