473,400 Members | 2,145 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,400 software developers and data experts.

store data in a struct

11
hello, im completely new to c and programming.

now i need to store data from a input buffer in a struct and then sending the struct back, not the buffer, but i dont know how to start.any help would be nice. thx
Nov 16 '07 #1
7 4072
Meetee
931 Expert Mod 512MB
hello, im completely new to c and programming.

now i need to store data from a input buffer in a struct and then sending the struct back, not the buffer, but i dont know how to start.any help would be nice. thx
Refer the following link. It will give you an idea about how to store data in buffer.
http://faq.cprogramming.com/cgi-bin/...wer=1044873249

You can store this data from buffer to struct variable. To know more search google for "struct in C"

Regards
Nov 16 '07 #2
TYF
11
thx zodilla58, i read all this, but its not exactly what im looking for and i also know most of them already. i should be more specific, but how when i have absolutely no clue what to do!! damn, thanks god its w-end!
Nov 16 '07 #3
TYF
11
too bad, im still on the office working on this.

new question. is there any way to get the size of, or indexing a void type buffer?
for now, i malloced some space and put all the data in this temp buffer to work with, but i guess there is some better ways to do this.
Nov 16 '07 #4
oler1s
671 Expert 512MB
now i need to store data from a input buffer in a struct
Then this struct better have a buffer within it big enough to store the data from the input buffer.

then sending the struct back
Which shipping company are you using to send the struct back? I hear UPS is really bad, but FedEx is quite good if not more expensive.

new question. is there any way to get the size of, or indexing a void type buffer?
Void is not a type so much as a lack of type. You can’t declare something of type void. If you have a void pointer, you can’t do any dereference operations, or get the size, as it is typeless.

or now, i malloced some space and put all the data in this temp buffer to work with
Well, you do have to allocate memory somehow, either on the stack or dynamically through malloc or whatever.

As far as I can understand, you’re just trying to copy the contents of one buffer into another. It’s a simple memory copy. We could assist you better, if you gave more details. You show no code. You don’t use good terminology. We are left confused.
Nov 16 '07 #5
Dear,
Type below code:

typedef struct _EXAMPLE
{
int i;
int c;
}EXAMPLE;

EXAMPLE GetSum(int k1,int k2)
{
EXAMPLE ex;
ex.i=k1;
ex.c=k2;
return ex;
}

//CPP file
EXAMPLE exx;
exx=GetSum(20,30);
cout<<"i"<<exx.i;
cout<<"c"<<exx.c;

Output
i =20
c=30
if you declare your struct in header file YOU MUST ADD #include "myheader.h"
at the first of implementation file(CPP) in your project after #stdafx.h
Nov 17 '07 #6
oler1s
671 Expert 512MB
Mostafa, your code is nonsensical. You have not read the forum rules. And you haven't read the OP's question, in which he states he is using C.

I suggest you spend some time doing some reading: forum rules and your C and C++ books before you give out advice. You'll end up misleading the OP with ridiculous answers.
Nov 17 '07 #7
TYF
11
hello,
i wasnt able to work on at the w-end, sorry for not posting.im so sorry leaving you confused, im still confused too.i do and did alot of researching before bothering you guys posting on this forum.but i just didnt found the relevant infos.i didnt post any code cause of security and copyright reason.and i use wrong terminology and bad english cause english isnt my native language and i never learned something about programming at school.for me learning the syntax of c is easy but to understand what every thing is doing is another thing.
may programming isnt for everyone.

thx to mustafa for trying to help.however im not into c++ while i still dont get c.

i guess it isnt just simple memory copying, i will post some code examples..
Nov 19 '07 #8

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

Similar topics

2
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
11
by: mwebel | last post by:
Hi, i had this problem before (posted here and solved it then) now i have the same problem but more complicated and general... basically i want to store the adress of a istream in a char* among...
1
by: slrj | last post by:
Can I use a local struct to store data in the "set" conatiner? If so, what is the correct method to do so? Compiler: Sun Studio 10 on Unix (Sun Solaris) #include<iostream> #include<set> ...
13
by: liujiaping | last post by:
Hi, all. I have a dictionary-like file which has the following format: first 4 column 7 is 9 a 23 word 134 .... Every line has two columns....
8
by: mathieu | last post by:
Hi, I was trying to make an entry in a std::map be stored more efficiently. The struct contained 3 booleans discribing it's property, so I am trying to make it as compact as possible. Using a...
45
by: Dennis | last post by:
Hi, I have a text file that contents a list of email addresses like this: "foo@yahoo.com" "tom@hotmail.com" "jerry@gmail.com" "tommy@apple.com" I like to
2
by: Laszlo Nagy | last post by:
Hi, I'm working on a pivot table. I would like to write it in Python. I know, I should be doing that in C, but I would like to create a cross platform version which can deal with smaller...
3
by: M.-A. Lemburg | last post by:
On 2008-08-07 20:41, Laszlo Nagy wrote: 1 It also very fast at dumping/loading lists, tuples, dictionaries, floats, etc. -- Marc-Andre Lemburg eGenix.com
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...
0
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,...
0
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...

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.