472,792 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,792 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 4049
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
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.