嵌入式面试题2016最新
嵌入式系统一般指非PC系统,通常完成一种或多种特定的计算机功能。那么嵌入式C语言难不难,下面yjbys小编为大家分享最新嵌入式C语言面试试题,欢迎参考学习!
1. 以下三条输出语句分别输出什么?[C易]
char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << boolalpha << ( str1==str2 ) << endl; // 输出什么?
cout << boolalpha << ( str3==str4 ) << endl; // 输出什么?
cout << boolalpha << ( str5==str6 ) << endl; // 输出什么?
13. 非C++内建型别 A 和 B,在哪几种情况下B能隐式转化为A?[C++中等]
答:
a. class B : public A { ……} // B公有继承自A,可以是间接继承的
b. class B { operator A( ); } // B实现了隐式转化为A的转化
c. class A { A( const B& ); } // A实现了non-explicit的'参数为B(可以有其他带默认值的参数)构造函数
d. A& operator= ( const A& ); // 赋值操作,虽不是正宗的隐式类型转换,但也可以勉强算一个
12. 以下代码中的两个sizeof用法有问题吗?[C易]
void UpperCase( char str[] ) // 将 str 中的小写字母转换成大写字母
{ for( size_t i=0; iif( 'a'<=str[i] && str[i]<='z' )
str[i] -= ('a'-'A' );
} char str[] = "aBcDe";
cout << "str字符长度为: " << sizeof(str)/sizeof(str[0]) << endl;
UpperCase( str );
cout << str << endl;
7. 以下代码有什么问题?[C难]
void char2Hex( char c ) // 将字符以16进制表示
{ char ch = c/0x10 + '0'; if( ch > '9' ) ch += ('A'-'9'-1);
char cl = c%0x10 + '0'; if( cl > '9' ) cl += ('A'-'9'-1);
cout << ch << cl << ' ';
} char str[] = "I love 中国";
for( size_t i=0; ichar2Hex( str[i] );
cout << endl;
4. 以下代码有什么问题?[C++易]
struct Test
{ Test( int ) {}
Test() {}
void fun() {}
};
void main( void )
{ Test a(1);
();
Test b();
();
}
5. 以下代码有什么问题?[C++易]
cout << (true?1:"1") << endl;
8. 以下代码能够编译通过吗,为什么?[C++易]
unsigned int const size1 = 2;
char str1[ size1 ];
unsigned int temp = 0;
cin >> temp;
unsigned int const size2 = temp;
char str2[ size2 ];
9. 以下代码中的输出语句输出0吗,为什么?[C++易]
struct CLS
{ int m_i;
CLS( int i ) : m_i(i) {}
CLS()
{ CLS(0);
} };
CLS obj;
cout << obj.m_i << endl;
10. C++中的空类,默认产生哪些类成员函数?[C++易]
答:
class Empty
{ public:
Empty(); // 缺省构造函数
Empty( const Empty& ); // 拷贝构造函数
~Empty(); // 析构函数
Empty& operator=( const Empty& ); // 赋值运算符
Empty* operator&(); // 取址运算符
const Empty* operator&() const; // 取址运算符 const
};
3. 以下两条输出语句分别输出什么?[C++难]
float a = 1.0f;
cout << (int)a << endl;
cout << (int&)a << endl;
cout << boolalpha << ( (int)a == (int&)a ) << endl; // 输出什么?
float b = 0.0f;
cout << (int)b << endl;
cout << (int&)b << endl;
cout << boolalpha << ( (int)b == (int&)b ) << endl; // 输出什么?
2. 以下反向遍历array数组的方法有什么错误?[STL易]
vector array;
_back( 1 );
_back( 2 );
_back( 3 );
for( vector::size_type i=()-1; i>=0; --i ) // 反向遍历array数组
{ cout << array[i] << endl;
}
6. 以下代码有什么问题?[STL易]
typedef vector IntArray;
IntArray array;
_back( 1 );
_back( 2 );
_back( 2 );
_back( 3 );
// 删除array数组中所有的2
for( IntArray::iterator itor=n(); itor!=(); ++itor )
{ if( 2 == *itor ) e( itor );
}
11. 写一个函数,完成内存之间的拷贝。[考虑问题是否全面]
答:
void* mymemcpy( void *dest, const void *src, size_t count )
{
char* pdest = static_cast( dest );
const char* psrc = static_cast( src );
if( pdest>psrc && pdest{
for( size_t i=count-1; i!=-1; --i )
pdest[i] = psrc[i];
}
else
{
for( size_t i=0; ipdest[i] = psrc[i];
}
return dest;
}
int main( void )
{
char str[] = "0123456789";
mymemcpy( str+1, str+0, 9 );
cout << str << endl;
system( "Pause" );
return 0;
}
-
经典C语言面试算法题
1.写一个函数,它的原形是intcontinumax(char*outputstr,char*intputstr)功能:在字符串中找出连续最长的数字串,并把这个串的长度返回,并把这个最长数字串付给其中一个函数参数outputstr所指内存。例如:"abcd12345ed125ss123456789"的首地址传给intputstr后,函数将返...
-
学习嵌入式的技巧
1、安全和备份:对于生产型系统,安全最重要。一旦发现安全问题,管理员首先就要停止相应的服务,查看日志,执行备份,以及打补丁。世界上没有什么东西是绝对安全的,Linux系统也并非百分之百安全,所以每天进行日常备份十分必要。2、安装Linux操作系统:通过对Linux操作系统的`...
-
什么是嵌入式系统
嵌入式系统是一种"完全嵌入受控器件内部,为特定应用而设计的专用计算机系统",根据英国电气工程师协会的定义,嵌入式系统为控制、监视或辅助设备、机器或用于工厂运作的设备。yjbys小编收集了一些嵌入式系统的概念,希望大家认真学习!1.嵌入式系统概述应该肯定地讲我...
-
嵌入式车库管理系统设计
过去智能卡应用领域常采用磁卡或接触式IC卡,但由于读写速度慢,易损坏,使用寿命比较短,无法保证系统长期运行的可靠性和方便性。非接触式IC卡由于使用方便、交易速度快、便于维护和使用寿命较长等优点,正在各种场合逐渐替代目前广泛使用的接触式IC卡。我们对现代化车...