GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-Sep-2007, 08:38
sams sams is offline
New Member
 
Join Date: Sep 2007
Posts: 2
sams is on a distinguished road
Lightbulb

Encoding and decoding of data


A linked list of characters is to be sent across a network in the form of a stream of bytes.Write the code in C language for encoding the data structure on the sender side and decoding it on the receiver side.

I could write it in short like this but not getting it exactly......

CPP / C++ / C Code:
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
typedef struct node
{
    int val;
    struct node *l,*r;
    mtype m;
}
buildmessage(node *r)
{
     if(r!=NULL)
     {
        m+=*r;
        buildmessage(r->l);
        buildmessage(r->r);
     }
}   

node *extractmessage()
{
    node *t;
    t=(node *)malloc(sizeof(node));
    while(m-=(*t))
    t=(node *    )malloc(sizeof(node));
    return(t);
}
Last edited by LuciWiz : 11-Sep-2007 at 14:47. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 11-Sep-2007, 10:45
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,703
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Encoding and decoding of data


Quote:
Originally Posted by sams
A linked list ...

1. What, exactly, is the assignment? Is it assumed that you will be presented with a "linked list of chars" and you have to get them into an array of chars in a form suitable for transmission over a network (with some kind of encoding algorithm that processes the stream of chars)? Are you supposed to implement functions to get stuff into and out of the linked list? Or what?

2. Regardless of what you are given or what is assumed, how are you going to test whatever part of the project it is that you are going to implement? (A main() function that calls the various functions?)

3. What, exactly, would you like for us to do for you? I mean, speaking for myself, nothing among the lines of (approximately) C code that you posted makes much sense, either by itself or in the context of writing code for "encoding the data structure" (whatever that means).

There may be lots of people who would like to help, but you have given us not much to work with.

Regards,

Dave
  #3  
Old 11-Sep-2007, 19:01
sams sams is offline
New Member
 
Join Date: Sep 2007
Posts: 2
sams is on a distinguished road

Re: Encoding and decoding of data


The linked list of characters is assumed to be there that is to be sent across a network in the form of a stream of bytes.A C program is needed to encode the data structure on the sender side and decode it on the receiver side.Simple C functions are needed to write the code.I meant no algorithms as such..
  #4  
Old 11-Sep-2007, 20:57
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 470
Howard_L has a spectacular aura aboutHoward_L has a spectacular aura about

Re: Encoding and decoding of data


Quote:
A C program is needed to encode the data structure on the sender side
Then start there.

Make a program where:
- you type in data,
- it encodes the data one char at a time,
- and sends encoded data to a file.

Then make a program where:
- it opens the file of encoded data,
- decodes it one char at a time,
- and prints the decoded data to the screen...

Don't worry about storing it in a linked list or array at first.
Just take one char , encode , send ,,, and vice versa.

THEN move into storage procedures.
and THEN move into sending accross the network...

Let us know where you get stuck and we'll have something to start with.
We can't be putting it all together for you... but we're happy to help YOU build the pieces.
Howard;
  #5  
Old 12-Sep-2007, 06:04
Uten Uten is offline
New Member
 
Join Date: Jan 2007
Location: Norway
Posts: 17
Uten is on a distinguished road

Re: Encoding and decoding of data


Do I understand the task at hand that Encoding is converting data from a linked list to a byte array (stream) and decoding is taking the byte stream and recreate the linked list again?

Do you have to write the network code? Or is that part supposed to be simulated?
  #6  
Old 12-Sep-2007, 09:38
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 470
Howard_L has a spectacular aura aboutHoward_L has a spectacular aura about

Re: Encoding and decoding of data


Now that is a puzzle isn't it? (I think it's encoded)...
He says a: ' linked list of characters is assumed to be there'
...then:
'encode the data structure on the sender side and decode it on the receiver side'

I took 'Encoding' to mean converting the chars to be unreadable as in using these two sets:
CPP / C++ / C Code:
char plainset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890.,!()?";
char cryptset[] = "DYx4NH3a7g18O?KsEIdFry5QlPu)w,B2McCTzA!mqZ(b6iSoW9neX.pfRtVUkL0vGhJj";
...to encode and decode. You would need to have the same encoding sets on both sides.
I GUESS the linked list 'structures' would be merely something like:
CPP / C++ / C Code:
struct blah {
  char c;
  struct blah *p_blah;
}
...and you just build the linked list on the reciever side as it is recieved.
Maybe we'll find out? Stay tuned for the next episode!
Howard;
 
 

Recent GIDBlogToyota - 2008 September Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:28.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.