Passing struct through unix pipe -solved


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Passing struct through unix pipe -solved
# 1  
Old 03-06-2010
Passing struct through unix pipe -solved

EDIT: Nevermind, called a friend who is good at this stuff and he figured it out Smilie

Hi all,

So I'm trying to teach myself to write programs for unix in c. I am currently creating a program, and I need to pass a struct through a pipe, but I can't figure out how.

The struct I want to pass has two types in it, one enum and one union of two other structs. These two other structs each contain an int and a char variablename[256] array.

gcc won't let me just pass the struct using write(pipefd[1], struct, size_of_struct) since the struct is not a char buffer. So that's my question...how does one go about passing a struct?

Thanks!

EDIT: Nevermind, called a friend who is good at this stuff and he figured it out Smilie

Last edited by twnsfn34; 03-06-2010 at 10:51 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help on passing an input variable to the voronota program (after third pipe)

Dear UNIX forum members, I am using macbook pro 13 (2015 edition) with MAC OS Mojave and am trying to write the shell script where when it is run through terminal it asks for an input (in the code below an input variable is domains) and then that input becomes capital letter or letters which... (3 Replies)
Discussion started by: Aurimas
3 Replies

2. UNIX for Dummies Questions & Answers

[Solved] How to swap PIPE seperator delimiter?

I have file like below 1|4|OR|OLAP|INT|INT||CONSTANT|2012/08/07|9999/12/31|0|0|0|0|PRL|-358.1684563||||||||||36522|55791|LNR| 2|4|OR|OLAP|CLR|CLR||CONSTANT|2012/09/07|9999/12/31|0|0|0|0|PRL|-358.1684563||||||||||36522|57891|REGS|... (2 Replies)
Discussion started by: gkskumar
2 Replies

3. Shell Programming and Scripting

[SOLVED] nawk FS using pipe read variables from file

I have a file data_1.out which contains: 1|abc mail|mail subject|mail body 2|def mail|mail subject|def mail body I am trying to read the variables from data_1.out and use them to print to 2 different files based on the id (first_column) The problem is I am not able to read the file... (8 Replies)
Discussion started by: sol_nov
8 Replies

4. Programming

[solved]help passing array of structs to function in c

this is my code to try and prinnt out a deck of cards. the print function worked when used inside main without being a function but now i cant get it to work as a function probably since i dont know how to pass a struct array in c. I gave it a shot but i keep getting an assortment of errors. The... (0 Replies)
Discussion started by: bjhum33
0 Replies

5. Programming

Storing C++-struct in file - problem when adding new item in struct

Hi, I have received an application that stores some properties in a file. The existing struct looks like this: struct TData { UINT uSizeIncludingStrings; // copy of Telnet data struct UINT uSize; // basic properties: TCHAR szHost; //defined in Sshconfig UINT iPortNr; TCHAR... (2 Replies)
Discussion started by: Powerponken
2 Replies

6. Programming

Passing an instance of struct to functions in other src files

I am trying to work out the best syntax for a relatively simple operation. The goal is to declare an instance of a struct and pass it around to be populated and have the data manipulated. There is an extra wrinkle in that the functions are in different src files. The main is simple, #include... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

7. Homework & Coursework Questions

Passing pointers to struct

Hi, i'm trying to copy a struct into a binary file using the unix instruction write, so i declare and fill the struct "superbloque" in one function "initSB" and then i pass the pointer to another function called bwrite (for block write) which calls write. The problem is that i call the function... (2 Replies)
Discussion started by: ignatius3
2 Replies

8. UNIX for Dummies Questions & Answers

How to access a struct within a struct?

Can someone tell me how to do this? Just a thought that entered my mind when learning about structs. First thought was: struct one { struct two; } struct two { three; } one->two->three would this be how you would access "three"? (1 Reply)
Discussion started by: unbelievable21
1 Replies

9. UNIX for Dummies Questions & Answers

Standard error output to Pipe input - solved

Hi, I want to check a particular word is in standard error output or not. Can I acheive it in single command? For example, Delete file_name 2>error.log cat error.log Output: XXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX Successfully deleted XXXXXXXXXXXXXXXXX where delete is... (2 Replies)
Discussion started by: poova
2 Replies

10. UNIX for Advanced & Expert Users

Passing socket struct between kernel threads - module programming

I write kernel module with kernel threads using linux/kthread.h on 2.6.* kernel I tried to passing data between two kernel threads with data argument of kthread_run( fun, data , NAME ); but this is not work I dont know why. I tried many possibility and nothing works. So I thought that... (0 Replies)
Discussion started by: marcintom
0 Replies
Login or Register to Ask a Question
tensor(2rheolef)						    rheolef-6.1 						  tensor(2rheolef)

NAME
tensor - a N*N tensor, N=1,2,3 SYNOPSYS
The tensor class defines a 3*3 tensor, as the value of a tensorial valued field. Basic algebra with scalars, vectors of R^3 (i.e. the point class) and tensor objects are supported. IMPLEMENTATION
template<class T> class tensor_basic { public: typedef size_t size_type; typedef T element_type; // allocators: tensor_basic (const T& init_val = 0); tensor_basic (T x[3][3]); tensor_basic (const tensor_basic<T>& a); // affectation: tensor_basic<T>& operator = (const tensor_basic<T>& a); tensor_basic<T>& operator = (const T& val); // modifiers: void fill (const T& init_val); void reset (); void set_row (const point_basic<T>& r, size_t i, size_t d = 3); void set_column (const point_basic<T>& c, size_t j, size_t d = 3); // accessors: T& operator()(size_type i, size_type j); T operator()(size_type i, size_type j) const; point_basic<T> row(size_type i) const; point_basic<T> col(size_type i) const; size_t nrow() const; // = 3, for template matrix compatibility size_t ncol() const; // inputs/outputs: std::ostream& put (std::ostream& s, size_type d = 3) const; std::istream& get (std::istream&); // algebra: bool operator== (const tensor_basic<T>&) const; bool operator!= (const tensor_basic<T>& b) const { return ! operator== (b); } template <class U> friend tensor_basic<U> operator- (const tensor_basic<U>&); template <class U> friend tensor_basic<U> operator+ (const tensor_basic<U>&, const tensor_basic<U>&); template <class U> friend tensor_basic<U> operator- (const tensor_basic<U>&, const tensor_basic<U>&); template <class U> friend tensor_basic<U> operator* (int k, const tensor_basic<U>& a); template <class U> friend tensor_basic<U> operator* (const U& k, const tensor_basic<U>& a); template <class U> friend tensor_basic<U> operator* (const tensor_basic<U>& a, int k); template <class U> friend tensor_basic<U> operator* (const tensor_basic<U>& a, const U& k); template <class U> friend tensor_basic<U> operator/ (const tensor_basic<U>& a, int k); template <class U> friend tensor_basic<U> operator/ (const tensor_basic<U>& a, const U& k); template <class U> friend point_basic<U> operator* (const tensor_basic<U>&, const point_basic<U>&); template <class U> friend point_basic<U> operator* (const point_basic<U>& yt, const tensor_basic<U>& a); point_basic<T> trans_mult (const point_basic<T>& x) const; template <class U> friend tensor_basic<U> trans (const tensor_basic<U>& a, size_t d = 3); template <class U> friend tensor_basic<U> operator* (const tensor_basic<U>& a, const tensor_basic<U>& b); template <class U> friend void prod (const tensor_basic<U>& a, const tensor_basic<U>& b, tensor_basic<U>& result, size_t di=3, size_t dj=3, size_t dk=3); template <class U> friend tensor_basic<U> inv (const tensor_basic<U>& a, size_t d = 3); template <class U> friend tensor_basic<U> diag (const point_basic<U>& d); template <class U> friend tensor_basic<U> identity (size_t d=3); template <class U> friend tensor_basic<U> dyadic (const point_basic<U>& u, const point_basic<U>& v, size_t d=3); // metric and geometric transformations: template <class U> friend U dotdot (const tensor_basic<U>&, const tensor_basic<U>&); template <class U> friend U norm2 (const tensor_basic<U>& a) { return dotdot(a,a); } template <class U> friend U dist2 (const tensor_basic<U>& a, const tensor_basic<U>& b) { return norm2(a-b); } template <class U> friend U norm (const tensor_basic<U>& a) { return ::sqrt(norm2(a)); } template <class U> friend U dist (const tensor_basic<U>& a, const tensor_basic<U>& b) { return norm(a-b); } T determinant (size_type d = 3) const; template <class U> friend U determinant (const tensor_basic<U>& A, size_t d = 3); template <class U> friend bool invert_3x3 (const tensor_basic<U>& A, tensor_basic<U>& result); // spectral: // eigenvalues & eigenvectors: // a = q*d*q^T // a may be symmetric // where q=(q1,q2,q3) are eigenvectors in rows (othonormal matrix) // and d=(d1,d2,d3) are eigenvalues, sorted in decreasing order d1 >= d2 >= d3 // return d point_basic<T> eig (tensor_basic<T>& q, size_t dim = 3) const; point_basic<T> eig (size_t dim = 3) const; // singular value decomposition: // a = u*s*v^T // a can be unsymmetric // where u=(u1,u2,u3) are left pseudo-eigenvectors in rows (othonormal matrix) // v=(v1,v2,v3) are right pseudo-eigenvectors in rows (othonormal matrix) // and s=(s1,s2,s3) are eigenvalues, sorted in decreasing order s1 >= s2 >= s3 // return s point_basic<T> svd (tensor_basic<T>& u, tensor_basic<T>& v, size_t dim = 3) const; // data: T _x[3][3]; }; typedef tensor_basic<Float> tensor; // inputs/outputs: template<class T> inline std::istream& operator>> (std::istream& in, tensor_basic<T>& a) { return a.get (in); } template<class T> inline std::ostream& operator<< (std::ostream& out, const tensor_basic<T>& a) { return a.put (out); } // t = a otimes b template<class T> tensor_basic<T> otimes (const point_basic<T>& a, const point_basic<T>& b, size_t na = 3); // t += a otimes b template<class T> void cumul_otimes (tensor_basic<T>& t, const point_basic<T>& a, const point_basic<T>& b, size_t na = 3); template<class T> void cumul_otimes (tensor_basic<T>& t, const point_basic<T>& a, const point_basic<T>& b, size_t na, size_t nb); rheolef-6.1 rheolef-6.1 tensor(2rheolef)