473,804 Members | 4,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1239
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
6829
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 assignment
7
1453
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 Idea = 5
4
2217
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 getting a program up and running with proper files and documentation to be handed in for a grade (on Microsoft Visual Studio .NET 2003). I am being graded on how well I incorporate advanced C++ features such as inheritance, polymorphic programming,...
3
5265
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 junitreport. I created a simple Math.java class which contains: package test; public class Math { public int add(int a, int b) { return a + b; }
6
5278
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
2101
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 don't somehow share the code. So, I copy the folder P1 is in, change the new folder name, and is VS2005 to change all occurrences of P1's name tp P2's name.
4
3472
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? http://bp2.blogger.com/_lZhqNsiakm4/Reh26hy-JHI/AAAAAAAAAAk/wvyV3Yx8gSs/s1600-h/gif_1.gif Thank you. sofeng
7
2304
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 files on harddisk there's a node into n- tree, this solution is not good for large hard disk.. and i can't use inotify (it's forbidden), and only c solutions are accepted without third party software or external calls.
1
2065
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 Matlab. However, if you have several c++/h files, then what's standard procedure to compile and link the files?
0
9589
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
10593
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...
1
10329
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
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
9163
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...
1
7626
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
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
3830
muto222
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.