Embedded Software face test One _ programming learning notes

Source: Internet
Author: User

1, please write what you know the C language keyword.

Auto: Declaring automatic variables

SWITCH: For switching statements

Case: Switch Statement Branch

Break: Jump out of the current loop

Default: The "other" branch in a switch statement

Continue: End current loop, start next round loop

Goto: Unconditional Jump Statement

Do: loop body of the loop statement

While: Looping conditions for circular statements

if: Conditional statement

ELSE: Conditional Statement Negative branch (used with IF)

Enum: Declaring an enumeration type

Union: Declaring a shared data type

extern: Declaring a variable is declared in another file

For: A circular statement

Register: Declaring Register variables

Return: The subroutine returns the statement (can be with parameters or without parameters) loop condition

sizeof: Calculating data type length

Static: Declaring statically variable

struct: Declaring struct-body variables or functions

typedef: Used to alias data types

Unsigned: Declaring unsigned type variables or functions

Void: Declares that the function has no return value or no arguments and declares no type pointer

Volatile: Description variables can be implicitly changed in program execution

Short: Declaring an integer variable or function

Signed: Declaring a signed type variable or function

Char: Declaring a character type variable or function

float: Declaring floating-point variables or functions

int: Declaring an integer variable or function

Long: Declaring an integer variable or function

Const: Declaring read-only variables

Double: declaring a double variable or function

2, IPv4 all the IP address into a, B, C, D, e five categories. Please write out the scope and mask of Class B address and Class C address, what is the use of Class D addresses.

Classification prefix code start address end address corresponding CIDR modified default subnet mask

Class A address 0 0.0.0.0 127.255.255.255/8 255.0.0.0

Class B address 10 128.0.0.0 191.255.255.255/16 255.255.0.0

Class C address 110 192.0.0.0 223.255.255.255/24 255.255.255.0

Class D address (group broadcast) 1110 224.0.0.0 239.255.255.255/4 undefined

Class E Address (reservation) 1111 240.0.0.0 255.255.255.255/4 undefined

3. Please describe the differences between multiple process programs and multithreaded programs in Linux.

4, listing the current Linux system can support the file system, listing more than four commonly used.

Ext3 ext4 jffs2 yffs2 ubifs Cramfs

5, write a "standard" macro min, this macro input two parameters and return the smaller one.

#define MIN (A, B) ((a) <= (b): (a)? (b))

6, what is the role of Mmu,mmu.

MMU is the abbreviation of Memory Management unit, which is responsible for the conversion of virtual address to physical address, and provides the memory access authorization of hardware mechanism.


7, the keyword volatile have what meaning, and give a few application occasions.

1. The variables defined should be variable to prevent compiler optimizations, allowing the program to access the original memory address directly.

2. Variables modified in the Interrupt service program for testing by other programs require additional volatile.

3. The signs shared between tasks in a multitasking environment should be added volatile.

4. Memory-mapped hardware registers are usually also voliate, because each read and write to it may have different meanings.

5. Frequent use of volatile is likely to increase code size and reduce performance.

8, bidirectional linked list operation question:

/* Node Definition * *

typedef srruct Node

{

struct node *next;

struct node *previous;

}node;

/* List Definition * *

typedef struct

{

Node node;

int count;

} LIST;

#define HEAD Node.next

#define TALL node.previous

/* Initialize a linked list * *

void Lstinit (LIST *plist)

{

pplist->head=null;

pplist->tall=null;

pplist->count=0;

}

Write a function to insert a node (pnode) after a node (Pprev) in the list plist.

9, please write the difference between strcpy and memcpy
1, strcpy and memcpy are standard C library functions.
2, strcpy provides a copy of the string. That is, strcpy is used only for string copying, and it also copies the end character of the string, not just the string content.
3, the prototype of the strcpy function is: char* strcpy (char* dest, const char* SRC);
4, MEMCPY provides a general memory of the replication. That is, memcpy has no limitations on what needs to be replicated, so it is more versatile.
5, the prototype of the memcpy function is: void *memcpy (void *dest, const void *SRC, size_t count);
strcpy and memcpy mainly have the following 3 differences.
5.1, the content of replication is different. strcpy can only copy strings, and memcpy may copy arbitrary content, such as character arrays, integers, structs, classes, and so on.
5.2, the method of replication is different. strcpy does not need to specify a length, it encounters the string end of the copied character "" "only to end, so it is easy to overflow. memcpy determines the length of the copy based on its 3rd parameter.
5.3, the use of different. Typically, you use strcpy when you copy strings, and when you need to copy other types of data, you usually use memcpy.

6. Realize prototype:

Char *strcpy (char* strdest, const char* STRSRC)
{

if ((strdest = NULL) | | (strsrc = NULL))
return NULL;
char* strdestcopy = strdest;

while ((*strdest++ = *strsrc++)!= '/0 ');

return strdestcopy;
}

void *memcpy (void *dest, const void *SRC, size_t count)
{
char *tmp = dest;
const char *s = SRC;

while (count--)
*tmp++ = *s++;
return dest;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.