1. Please write a C function that searches for a given character in a given memory area and returns the index value of the character's location.
Answer:
int search(char *cpSource, int n, char ch)
{
int i;
for(i=0; i
return i;
}
2. A singly linked list, with an unknown head node, and a pointer pointing to one of the nodes. How to delete the node pointed to by this pointer?
Answer:
Copy the value of the next node pointed to by this pointer to this node, set next to next->next, and then delete the node pointed to by next.
3. Write a function to compare the sizes of two strings str1 and str2. If they are equal, it returns 0; if str1 is greater than str2, it returns 1; if str1 is less than str2, it returns -1.
Answer:
int strcmp ( const char * src,const char * dst)
{
int ret = 0 ;
while( ! (ret = *(unsigned char *)src - *(unsigned char *)dst) && *dst)
{
++src;
++dst;
}
if ( ret < 0 )
ret = -1 ;
else if ( ret > 0 )
ret = 1 ;
return( ret );
}
Reference address:C language test questions 2
Answer:
int search(char *cpSource, int n, char ch)
{
}
2. A singly linked list, with an unknown head node, and a pointer pointing to one of the nodes. How to delete the node pointed to by this pointer?
Answer:
Copy the value of the next node pointed to by this pointer to this node, set next to next->next, and then delete the node pointed to by next.
3. Write a function to compare the sizes of two strings str1 and str2. If they are equal, it returns 0; if str1 is greater than str2, it returns 1; if str1 is less than str2, it returns -1.
Answer:
int strcmp ( const char * src,const char * dst)
{
}
Previous article:C language test questions five
Next article:C language test questions 4
Latest Microcontroller Articles
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
MoreDaily News
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
Guess you like
- Share CC2541 Bluetooth Learning About Watchdog
- [National Technology Low Power Series N32L43x Review] 05. SPI drive TFT screen & TF card to achieve Chinese and English mixed display
- How to prevent LCD screen from moisture and humidity
- Ask for help 50 E coins
- How to use a soldering iron well
- The process of making a stopwatch
- ②. Build development environment and running lights
- Comparison between altera's USB BLASTER II and USB BLASTER
- Let's talk about the Miller effect of electron tubes
- An example of how to call an assembly function in KEIL C51 (v6.21)