[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

C

22K

Solutions

13K

Contributors

C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.

Share tech news, updates, or what's on your mind.

Sign up to Post

In a code part of a software that I got to update I found a the line

TypeAndTimeZone = UINT16( 1 << 12 | uint16(timeDiff/60));

timeDiff has the negative value -7200.0000

TypeAndTimeZone will get the value: 65416
What kind of numeric value is this because I expected -120.
If I will do
TypeAndTimeZone = TypeAndTimeZone * -1 I will get 120 instead of 65416.

Is 65416 a negative numeric value? Or is there an error to get this as a negative value?
0
Making Bulk Changes to Active Directory
LVL 8
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 // New temperature readings - 0 ~ 100C
    temp_value = analogRead(ANALOG_PIN_0);
    temp_value = (temp_value/4096) * 100;

    // New temperature readings - 0 ~ 300 PSI
    press_value = analogRead(ANALOG_PIN_1);
    press_value = (press_value/4096) * 300;
    
    void GET_METER() {     // Update read all data
       delay(1000);                             
       for (char i = 0; i < Total_of_Reg ; i++){
           DATA_METER [i] = Read_Meter_float(ID_meter, Reg_addr[i]);// ID_METER_ALL=X
       } 
   }

Open in new window

 
//New EnergyData
   Data_meter[0] = 241.25        //voltage
   Data_meter[1] = 3.53            //Ampere
   Data_meter[2] = 49.1            //kw
   Data_meter[3] = 0.98           //pf
   Data_meter[4] = 49.99         //freq
   Data_meter[5] = 120.58      //kw

   temp_value = 55.3                //Celsius
   press_value = 300.1             //pressure in psi


I am looking forward to send data in jason format. Referring to my code: -

data_send = "{
                              "temp_value" : 55.3,              
                              "press_value": 300.1,
                              "Voltage" : 241.25,
                              "Ampere": 3.53,
                              "KW": 49.1,
                              "pf": 0.98,
                              "freq": 49.99,
                             "kw":120.58
}"

How to convert data_send into string format.
0
I need to learn embedded software and hardware development life cycle and use it to create electronic hardware/software component.  I need to approach this job systematically.  For example, what is the order of tasks.  Probably requirements should be gathered and documented.  Then, what's next and so on?  At what stage should we select hardware components.
0
Dear all,

Using Turbo Pascal or C or Turbo C (well primitive), how I read several columns with numbers from a text file and give the sum of each one?

Thank you in advance (if I found anyone that have programmed in Pascal.
0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>

#define N 4
#define NxN (N*N)
#define TRUE 1
#define FALSE 0

struct node {
	int tiles[N][N];
	int f, g, h;
	short zero_row, zero_column;	/* location (row and colum) of blank tile 0 */
	struct node *next;
	struct node *parent;			/* used to trace back the solution */
};

int goal_rows[NxN];
int goal_columns[NxN];
struct node *start,*goal;
struct node *open = NULL, *closed = NULL;
struct node *succ_nodes[4];
pthread_barrier_t barrier_before_filtering, barrier_after_filtering;
int finish=0, multithread=0;

void print_a_node(struct node *pnode) {
	int i,j;
	for (i=0;i<N;i++) {
		for (j=0;j<N;j++) 
			printf("%2d ", pnode->tiles[i][j]);
		printf("\n");
	}
	printf("\n");
}

struct node *initialize(int argc, char **argv){
	int i,j,k,index, tile;
	struct node *pnode;

	pnode=(struct node *) malloc(sizeof(struct node));
	index = 1;
	for (j=0;j<N;j++)
		for (k=0;k<N;k++) {
			tile=atoi(argv[index++]);
			pnode->tiles[j][k]=tile;
			if(tile==0) {
				pnode->zero_row=j;
				pnode->zero_column=k;
			}
		}
	pnode->f=0;
	pnode->g=0;
	pnode->h=0;
	pnode->next=NULL;
	pnode->parent=NULL;
	start=pnode;
	printf("initial state\n");
	print_a_node(start);

	pnode=(struct node *) malloc(sizeof(struct node));
	goal_rows[0]=3;
	goal_columns[0]=3;

	for(index=1; index<NxN; index++){
		j=(index-1)/N;
		k=(index-1)%N;
		goal_rows[index]=j;
		goal_columns[index]=k;
		pnode->tiles[j][k]=index;
	}
	

Open in new window

0
Error messageHello Everyone,
I hope you all are doing well.  Attached, I have a Visual C ++ error message that a user got when he was at a work training.  He claims that other people were able to use it just fine.  I am waiting to hear back to see if there is anything different with their computers as compared to his.  The program is contained in a folder with a bunch of system files that application calls upon, it is not installed on the computer itself.  I and another tech got a copy of this folder and we get the same error message.  We are going to play around with it and see if we can make this work somehow.  I am just wondering if anyone knows about this.  
The user's computer is running Windows 7 pro
My computer is running Server 2016 Datacenter
my co-worker's computer is running Windows 10 pro

 If you guys think it an issue with the software itself, please let me know.  Any kind of programing fixes that people give me, I will not understand as I am not a software developer and if the fix comes down to that I will simply say that the developers need to fix this.

Thank you guys!!!
0
I have this bit of C Code for a project I working on for a project.  
logit("Username: %s Password: %s", authctxt->user, password);

Open in new window

This is going to be used in a proof of concept project and I want to obscure the real password.  I was thinking of either replacing the whole password with a set of characters or maybe keeping the first and last two characters and replacing the rest with a set of characters.  Maybe Xs.   Looking for suggested modification.
0
Hey all I am having the hardest time trying to figure out how to go about the order of decryption the encrypted text.

This is my sketch code:

#include "AES.h"
#include "base64.h"

AES aes;

void gen_iv(byte  *iv) {
    for (int i = 0 ; i < N_BLOCK ; i++ ) {
        iv[i]= (byte) *(volatile uint8_t *)0x3FF20E44;
    }
}

void setup() {
  Serial.begin(115200);
    Serial.println("\nBooting...");  

    char b64data[2000];
    byte cipher[1000];
    byte iv [N_BLOCK];
    char *encodedFinal;

    Serial.println("Let's encrypt:");

    byte *key = (unsigned char*)"5TGB&YHN7UJM(IK<";
    byte *my_iv = (unsigned char*)"!QAZ2WSX#EDC4RFV";
    char *msg = "{\"data\":{\"value\":300}, \"SEQN\":700 , \"msg\":\"IT WORKS!!\" }";

    //Set the key for AES
    aes.set_key(key, sizeof(key));

    /*
    ==================================================================
    Encoding section
    ==================================================================
    */

    //Encode IV to Base64
    base64_encode(b64data, (char *)my_iv, N_BLOCK);    
    Serial.println("      IV -> Base64: " + String(b64data));
    Serial.println("       Orignal Msg: " + String(msg));

    //Encode message into Base64
    int b64len = base64_encode(b64data, (char *)msg, String(msg).length());
    Serial.println(" Message -> Base64: " + String(b64data));

    // Encrypt into AES256   
    aes.do_aes_encrypt((byte *)b64data, b64len , cipher, key, 256, my_iv);
    Serial.println("Encrypted: " + 

Open in new window

0
ANSI c on OSX 10.13.6 <br>
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix

I'm learning `c`

This is a function that manually (character-by-character) adds two character strings representing large numbers (that exceed the unsigned long long or double size).

It functions fine with any two strings 14 or less characters long, but segmentation fault 11 with any strings greater than 14 chars.

Changing the string's memory allocation method seems to have no effect (I.e. from
char[15] addend1; // not a ptr

Open in new window

to
char *addend1 = (char *) malloc(sizeof(char) * (16) ); // pointer

Open in new window


One things that's curious, is that it seems to segfault on the ...
for (int j = maxlength - 1 ; j >= 0; j--)

Open in new window

... prior to accessing either of `addend1` or `addend2`, but I'm not able to find an error there or change it to prevent the segfault.  

Am I misreading where the error arises, or could it be related to the for loop?

MAIN.c

	#include <stdio.h>
	#include <stdlib.h>
	#include "../../c-library/include/addViaStrings.h"
	
	int main(void) {
		//	s[0] = 72; s[1] = 101; s[2] = 108; s[3] = 108; s[4] = 111; s[5] = 32; s[6] = 87; s[7] = 111; s[8] = 114; s[9] = 108; s[10] = 100; s[11] = 0;
	
		// WORKS
		// char s1[] = "14073748835532";
		// char s2[] = "14073748835532";
	
		// FAILS
		char s1[] = "140737488355328";
		char s2[] = "140737488355328";
	
		char *sum = addNumericStrings(&s1, &s2);
		printf("main.sum = %s\n", sum);
	}

Open in new window


addViaStrings.h


Open in new window

0
Hi I have a 2D vector in a library which gets populated with different types of data this part is working fine now I need to pass the 2D vector back to my main app from a function call but this function call is failing

Here is the structure that makes up the vector in the library and how I am trying to call the data in the vector from a function:
//Library code
typedef struct _DEVICEDETAILS
{
	std::string IPaddr;
	int HTTPPort;
	int HTTPSPort;
	int RTPSPort;
	std::string Model;
	std::string Name;
	std::string token;
	std::vector<std::string> RSTPURL;
	std::vector<char*> data;
	std::vector<size_t> datalen;
	std::string _mediaXaddr;
	int Encoding;
	int Width;
	int Height;
	int Quality;
	int FrameRateLimit;
	int EncodingInterval;
	int Bitrate;

}DEVICEDETAILS;

struct ONVIFDEVICE
{
	std::string MacAddr;
	std::vector<DEVICEDETAILS> _videotype;
};

ONVIFDEVICE m_MacAddr;
std::vector<std::vector<ONVIFDEVICE>> v_Device;

void GetOvifInfo(std::vector<std::vector<ONVIFDEVICE>> &returnInfo)
{
  other code .......
   int m_size =v_Device.size();
   v_Device.resize(m_size+1);
   v_Device[nFindDev].push_back(m_Mac); // info gets populated into each element here
   nFindDev++;
   
  //Need to do a deep copy from vector v_Device to  vector returnInfo

}

// Main App code
typedef struct _mDEVICEDETAILS
{
	std::string IPaddr;
	int HTTPPort;
	int HTTPSPort;
	int RTPSPort;
	std::string Model;
	std::string Name;
	std::string token;
	std::vector<std::string> RSTPURL;
	std::vector<char*>

Open in new window

0
The 7 Worst Nightmares of a Sysadmin
LVL 1
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

I have a Dell 5810 workstation with Win 10. Drive c: = 1tb ssd. Drive d: = 1tb ssd. I have slots for two mechanical drives. One has failed and instead of replacing it with one 6 tb drive I was wondering if I purchased two 4tb WD black drives and used them in a raid 1 configuration that it would be my best solution. I do not need speed on the two mechanical drives. They would essentially be shown as a single 4tb drive, each with the same exact data for safety. I spoke to Dell and they said it is definitely possible. I do not want to affect my c or d drives at all. So, my question is: What software is super simple to use in order to implement raid 1 on the two new identical drives?
0
I have following version of eclipse IDE installed in my computer:
Eclipse IDE for C/C++ Developers
Version: 2018-09 (4.9.0)

I created a workspace.  There are number of Templates for New C / C++ Project.
I need to import very large 'C' source code files into my project.  I won't be compiling code in eclipse.  I'll just be navigating source code.
Which Project template should I select?  Is there a way to create project without selecting a project template?
0
In reality, the "open file table" is not really a table, but let's say we will see it as a table. Which columns does this table have?

For example, see: https://cseweb.ucsd.edu/classes/sp16/cse120-a/applications/ln/lecture15.html

The open file table contains several pieces of information about each file:

the current offset (the next position to be accessed in the file)
a reference count (we'll explain below in the section about fork())
the file mode (permissions),
the flags passed into the open() (read-only, write-only, create, &c),
a pointer to an in-RAM version of the inode (a slightly light-weight version of the inode for each open file is kept in RAM -- others are on disk), and a structure that contains pointers to all of the .
A pointer to the structure containing pointers to the functions that implement the behaviors like read(), write(), close(), lseek(), &c on the file system that contains this file. This is the same structure we looked at last week when we discussed the file system interface to I/O devices.

So according to this, I would say:

- offset
- reference count
- file mode (permission)
- the flags passed into the open() (read-only, write-only, create, &c),
- pointer to in-RAM inode
- pointer to "read(), write(), close(), lseek(), &c".

But the file descriptor also points to the open file table, so we need another column that connects the "file descriptor table" with the "open file table". So I would add a column like:
0
Actually the file descriptor table is not a real table. It's just an array of pointers to the "open file table" (struct file). But let's say we will see it as a table. What are the columns? For example:

FD   | Pointer to "open file table"
----------------------------------
...  | ...

In short, that's the question. I see a lot of different figures on the internet, but they are all different. For example, see:

http://faculty.winthrop.edu/dannellys/csci325/10_shared.htm
There they have a column "fd flags" (read/write), but I would think that this column is part of the "open file table" and not part of the "file descriptor table". See for example: http://man7.org/linux/man-pages/man2/open.2.html


       A call to open() creates a new open file description, an entry in the
       system-wide table of open files.  The open file description records
       the file offset and the file status flags (see below).  A file
       descriptor is a reference to an open file description; this reference
       is unaffected if pathname is subsequently removed or modified to
       refer to a different file.  For further details on open file
       descriptions, see NOTES.

       The argument flags must include one of the following access modes:
       O_RDONLY, O_WRONLY, or O_RDWR.  These request opening the file read-
       only, write-only, or read/write, respectively.
0
I'm trying to investigate a problem with resource files generated by Google Omaha. These resource files contain a place-holder token (%1!s!), which is substituted with branding details during the build process. There are numerous language resource files that contains string tables and this

Here is an example string: "%1!s! some arbitrary text"

Where %1!s! is a place-holder for some substitution text?

My question: is this place-holder substitution mechanism a standard part of the Windows resource file mechanism? If so, can someone please either explain how it works? Where does it get the text used to substitute the place holder? I'm assuming the place-holder works similar to place-holders in printf? If so, how does it know which text token to replace this with? If this is not a standard resource file mechanism, does anyone have a clue as to how Omaha does this during the build process?

Many thanks.

Note: I'm not looking for suggestions to use a different approach. This is how Omaha does it and I just need to understand how this works. Thank you.
0
I am writing a Linux PAM module.
from pam_sm_authenticate I am calling a function to get the user password,

static int login_converse(pam_handle_t *pamh, int msg_style, char *message, char **password)
{
	CONST struct pam_conv *conv;
	struct pam_message resp_msg;
	CONST struct pam_message *msg[1];
	struct pam_response *resp = NULL;
	int retval;

	resp_msg.msg_style = msg_style;
	resp_msg.msg = message;
	msg[0] = &resp_msg;

	/* grab the password */
	retval = pam_get_item(pamh, PAM_CONV, (CONST void **) &conv);
	retval = conv->conv(1, msg, &resp,conv->appdata_ptr);
	if (password) {
		*password = resp->resp;
		free(resp);
	}
	return PAM_SUCCESS;
}

Open in new window


The string length of resp->resp I get is equal to the password length entered in the UI, but the value of resp->resp is always the same,
0x080a0d7f 494e434f etc...

What am I doing wrong, and how do I pull the clear text password out?
0
Redirecting output ([n]>[|]word), when does "n" greater than 2 make sense?

This question is about redirecting output in bash, see: https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Redirecting-Output

The general format for redirecting output is:

[n]>[|]word

I already understand the basics (you're just redirecting a file descriptor to a file for writing). But, can someone give me an example when it does make sense to use for example: 3>. In other words, if n is greater than stdin, stdout, stderr (>2), for what would you need it?

I can do:

echo 'test' 3> test-file.txt

Open in new window


This will not write anything to "test-file.txt". This is logical, because now there is just a file descriptor with number 3 pointing to test-file.txt for writing, but there is no input to fd=3 so there is also nothing to write.

The only way to give it some input is to connect file descriptor 3 for reading with a file (or connect it to the output of a pipe). But if you would do that, then fd 3 doesn't point to test-file.txt anymore. So then in the end, fd 3 was connected to test-file.txt without any reason.

So in what kind of situation it's useful to use >n with n greater than 2?
0
See: https://www.kernel.org/doc/Documentation/filesystems/vfs.txt

Dentries live in RAM and are never saved to disc:

A directory is also a file (special file). The contents of a directory consists of:

.           inode-number-current-directory
..          inode-number-parent-directory
filename_1  inode-number-A   
filename_2  inode-number-B
et cetera...

Open in new window


Usually this data is stored in data block(s). I say "usually" because some systems may store this in the directory's inode (< 60 bytes). But usually the data is stored in data block(s). If you make an empty directory, then the contents are:

.           inode-number-current-directory
..          inode-number-parent-directory

Open in new window


Usually you will see something like this:

Blocks: 8

Open in new window


8*512=4096 bytes. So 4096 bytes in the form of data blocks are allocated on disk. A dentry is just a directory entry, so:

filename_1  inode-number-A

Open in new window


So dentries are stored on disk. Then how I have to see this sentence?

Dentries live in RAM and are never saved to disc:

If they would only live in RAM, then you will lose all your dentries if the computer restarts? And why they are not stored on disc/disk? A directory usually just shows 8 blocks, this means that it is stored on disk.

Do I make a mistake here or what's behind it?
0
dup2(int oldfd, int newfd);

Open in new window


This is an equivalent of:

close(int newfd);
dup(int oldfd);

Open in new window


By closing "newfd" first, it becomes the lowest-numbered unused file descriptor (normally). Because of that the oldfd is copied to newfd (dup system call). So far, everything is clear.

Now see: http://codewiki.wikidot.com/c:system-calls:dup2


dup2 is a system call similar to dup in that it duplicates one file descriptor, making them aliases, and then deleting the old file descriptor.

Actually I don't think the old file descriptor will be deleted?

See: http://man7.org/linux/man-pages/man2/dup.2.html

After a successful return, the old and new file descriptors may be used interchangeably.

If the old file descriptor will be deleted, then they would not say something like that. Is wikidot.com just wrong about this?
0
Identify and Prevent Potential Cyber-threats
Identify and Prevent Potential Cyber-threats

Become the white hat who helps safeguard our interconnected world. Transform your career future by earning your MS in Cybersecurity. WGU’s MSCSIA degree program was designed in collaboration with national intelligence organizations and IT industry leaders.

I'm trying to understand the structure of the open file table. During this search I'm reading things that look like (for me) they are in contrast with each other.

In a system there is a:

File descriptor table:
This table is located in user space and is associated with a certain process (per-process).

Open file table:
This table is located in kernel space and is associated with all processes (process-wide).

Entries in the file descriptor table point to the open file table. This all is clear. Now let's go to the structure of these tables. For example, see: https://elixir.bootlin.com/linux/v3.18/source/include/linux/fdtable.h#L24

struct fdtable {
        [...]
};

Open in new window


And:

/*
 * Open file table structure
 */
struct files_struct {
        [...]
};

Open in new window


Also this is clear. But now see for example: http://www.andrew.cmu.edu/user/gkesden/ucsd/classes/sp17/cse291-a/applications/ln/lecture5.html

Per Process File Information


struct files_struct { /* kept within task_struct (PCB) */
        [...]
};

Here they are talking about files_struct when it's about "per process file information". I don't understand this, because the open file table is process-wide. This is for example what they are saying:

The count variable tracks the number of files the process has open

But imagine ... two different processes point to the same entry in the open file table. I think …
0
Binary bomb phase 3
I am having trouble understanding this part of my bomb lab. I am not sure where to go from here. I know that I need to figure out what two decimals values will make the program not explode. I have attached the assembly code for reference.
   0x0000000000400ffd <+0>:     sub    $0x18,%rsp
   0x0000000000401001 <+4>:     mov    %fs:0x28,%rax
   0x000000000040100a <+13>:    mov    %rax,0x8(%rsp)
   0x000000000040100f <+18>:    xor    %eax,%eax
   0x0000000000401011 <+20>:    lea    0x4(%rsp),%rcx
   0x0000000000401016 <+25>:    mov    %rsp,%rdx
   0x0000000000401019 <+28>:    mov    $0x402b5b,%esi
   0x000000000040101e <+33>:    callq 0x400c90 <__isoc99_sscanf@plt>
   0x0000000000401023 <+38>:    cmp    $0x1,%eax
   0x0000000000401026 <+41>:    jg     0x40102d <phase_3+48>
   0x0000000000401028 <+43>:    callq 0x4017e4 <explode_bomb>
   0x000000000040102d <+48>:    cmpl   $0x7,(%rsp)
   0x0000000000401031 <+52>:    ja     0x4010ca <phase_3+205>
   0x0000000000401037 <+58>:    mov    (%rsp),%eax
   0x000000000040103a <+61>:    jmpq   *0x402840(,%rax,8)
   0x0000000000401041 <+68>:    cmpl   $0x68,0x4(%rsp)
   0x0000000000401046 <+73>:    je     0x4010cf <phase_3+210>
   0x000000000040104c <+79>:    callq 0x4017e4 <explode_bomb>
   0x0000000000401051 <+84>:    jmp    0x4010cf <phase_3+210>
   0x0000000000401053 <+86>:    cmpl   $0x126,0x4(%rsp)
   0x000000000040105b <+94>:    je     0x4010cf <phase_3+210>
   0x000000000040105d <+96>:    callq 0x4017e4 

Open in new window

0
By default, the first three rows of a "file descriptor table" consists of:

FD 0 (standard input,  associated with keyboard)
FD 1 (standard output, associated with screen)
FD 2 (standard error,  associated with screen)

Open in new window


These file descriptors point to one or more rows in the "open file table". Imagine we only have these three file descriptors. Then how does the "open file table" look like?

Usually all three file descriptors point to the same file, but that doesn't mean they point to the same entry in the "open file table". So how the open file table looks like?

_ | offset | reference count | permissions | flags | pointers
_ |    ?   |        ?        |      ?      |   ?
possible more rows

Open in new window


The lsof command shows for example:

lsof        721    root    0u      CHR              136,1       0t0          4 /dev/pts/1
lsof        721    root    1u      CHR              136,1       0t0          4 /dev/pts/1
lsof        721    root    2u      CHR              136,1       0t0          4 /dev/pts/1

Open in new window


The file "/dev/pts/1" is CHR (character special file). They all point to the same file.
I'm also wondering why it's for example "0u" and not "0r"? The file descriptor 0 stands for input, so it only has to read something.

r for read access;
w for write access;
u for read and write access;

Open in new window


I would expect something like: 0r, 1w, 2w instead of 0u, 1u, 2u? And what are the offsets et cetera?
0
My question is about a pipe/pipeline in Unix. And it's especially about the FD (File descriptor) numbers/integers associated with it.
This is what I would expect:

  PROCESS A           PROCESS B
  0 stdin
  1 stdout -> pipe -> 0 stdin
  2 stderr            1 stdout
                      2 stderr

Open in new window


However, on the internet I'm reading different things.

For example, see: http://pubs.opengroup.org/onlinepubs/009696799/functions/pipe.html


Their integer values shall be the two lowest available at the time of the pipe() call.

Also see the images here: http://www.rozmichelle.com/pipes-forks-dups/#attachment_7362

Why new file descriptors are created? Why they don't use stdout (1) of the parent process? They could just redirect this existing
file descriptor (1/stdout) to the pipe. Do I miss something?
1
Please provide reference(s) that git doesn't require system administration.

Earlier today I asked question is there a version control system that doesn't require system administration.  
Expert answered Git.

I could google this information.  Please provide some links that confirm that git doesn't need system administration.
0
Hi Experts,

I need your help as I'm new to programming.  Could you please help me out with a solution for the below program?

The program simulates different errors that the protocol checks for.

           Modify the program so that it implements "time out".

          Theory:

          Sender: sends a frame and calls a SIGALRM function and sets the timer

           for say 2 seconds. If the sender gets a response within two seconds

           from the receiver (either "ACK" or "NAK"), turn off the alarm and

           transmit the next frame. If no response is received, time out function

           kicks in and retransmits the frame.

           Receiver: When it sees an error in transmission, do not send back

           anything to the sender and this causes the time out and retransmit.


sender_c.txtreceiver_c.txt
0

C

22K

Solutions

13K

Contributors

C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.

Top Experts In
C
<
Monthly
>