Thanks all for the help.
Since the int array only has positive numeric values and I wanted the char array to contain the text format of each integer, I was able to make a simple assignment like so,
......includes......
#define size 2
int main()
{
int i;
int a[size] = {1,2}...
Thank you for the response sedj and xwb :)
xwb, you bring up a good point.
What I have is an integer array where each element is a number from 0-100. e.g. int array[100] = {1,2,66..etc};
In addition I have an unsigned char array and I would like this array to have "1 2 66..etc" since this...
Hello, I'm trying to convert an integer array into an unsigned char array, but my experience with this is limited. I don't want to lose any information during the conversion. Can anyone provide some tips?
The idea is to have a singly link list of nodes and each node has a local table of data represented by another link list. I know where the seg fault is coming from, but I don't know why. Rather than paste my whole program, I typed up this stub that shows what Im trying to do. If there are...
I'm using the indent utility to reformat c source files and I notice that the options you provide to the utility affects the whole file. I'm wondering if its possible to only format certain sections of code instead of formatting all the code in the input file.
For example I have a source file...
Thank you for the insightful advice Hammer. I was actually working up towards doing what you said by having a small header inside the main data structure to be sent. This header would contain fields for size of proceeding message, type, and a counter
typedef _HEADER {
int msg_size;
int...
I'm able to send and receive structures now but my implementation is slightly different from the advice I've been given here. Whether this is correct or if it's a viable solution in the long run I do not know for sure.
My structure
typedef struct _mystruct {
int size;
float value1;
}...
Thank you for your attention Clairvoyant1332. If I typecast the structure into a character pointer when I send and as I receive do I need to typecast the received buffer back into the original structure type?
I tried it like you suggested and I receive the correct bytes, however if I print...
Hello All,
I'm doing some socket programming and I need to pass data structures in a tcp/ip stream. I understand how to send character arrays in the buffer and parse it on the other end because I can pick apart the data one byte at a time. However I'm having some difficulty grasping the...
Firewalling is really not needed on this network so I definitely want to keep iptables disabled. I'm not really experienced with the program so not having to deal with it will save me some time. Unless it is the case that iptables is required for routing then I'll have to invest some time and...
The computers are in a secure lab and the floppy drives are disabled. Unfortunately I will not be able to copy and paste configs to make this troubleshooting easier. Following your advice this is what I did and here is the info I gathered.
1. Both machines can ping their 'eth0' and loopback...
Thank you again marsd. Your points on the default gateway make alot of sense. I reconfigured the routing table on each machine to look exactly like you had above. I didn't add subinterfaces because I wasn't sure I needed to since 'eth0' is configured properly and it's up and broadcasting...
Thanks for the attention marsd, but that doesn't doesn't appear to help.
Can you explain a little more about your comment on my default routing? My network experience has always been that I'm given a default gateway (via ISP, etc) and that is what I use for the routes. In this case, I am not...
Hello All,
I apologize in advance if this is the wrong forum for my question. I have many computers running under redhat 9.0 and I want them on a private lan. Everything is setup and I'm using the class A (10.0.0.0) addresses for them. All of the computers are connected to a 16 port linksys...
Thank you Salem. I really appreciate your input and time on this problem.
Your code will ensure the program reads in the correct size of the message. In my case, the structure I wrote earlier has 9 bytes. That solves the problem of making sure I receive the correct length of the message...
>ALWAYS check the return result - packet reassembly is >your problem in a TCP connection.
>There is not a 1:1 correspondence between the packets you >send and the packets you receive.
That would explain why the data is garbled. I'm just not sure how read the incoming data and reconstruct the...
Hello All,
I'm trying to create a distributed system using a tcp server/client model and I'm having trouble getting the clients and server to talk. The main communication protocol is to pass message structures over a connected socket but it appears the data is getting garbled after a...
Thank you for the attention Salem. You are right, I used scanf in an earlier section of my program because I needed to read in an integer and not a whole line. If I have to mix scanf and fgets, is it possible to flush the input buffer to solve the problem? Can I mix fgetc calls with fgets?
David
Hello All,
I'm experiencing some odd runtime behavior when using the fgets() function as an alternative to scanf(). I'm simply trying to read in some user input such as a string of text. I notice that if I use the fgets() call inside the main() routine, I get a user prompt. But if I call...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.