Gluster Interview Report
- 0of 0 votes
Answers2. write down Linux "grep" command code.
- siva.sai.2020 February 13, 2011
Input: file and a pattern
Eg.
$ Mygrep "siva*" names.txt
Output:
print entire line if it contains "Siva" word or prefix.
e.g:
"good bad siva is bad boy."
"sivabrtt gjfg"
After that asked me to write code to support regular expressions like "Siva*", "siva+venkat", "^siva".| Report Duplicate | Flag | PURGE
Gluster Software Engineer / Developer Algorithm - 0of 0 votes
Answers5) Can we crash a process before entering Main() function ?
I said possible and I give following two examples
example 1:int *i = 0; int j = *i; // I think here memory access violation since pointer 'i' pointing 0th address. int main() { return 0; }
Example 2:
int i = 1 / 0; // here Float point exception or divided by zero exception. int main() { return 0; }
Today I executed , above two examples and I am getting compile time error "Line 2: error: initializer element is not constant
- siva.sai.2020 February 13, 2011
" .
Can some one please tell me why I am getting compile time error ?| Report Duplicate | Flag | PURGE
Gluster Software Engineer / Developer C - 0of 0 votes
Answers3) Littele Endian vs Big Endian ?
- siva.sai.2020 February 13, 2011
Sub questions:
1) which one decides endianess , Processor(CPU) or Operating System ?
2) There any standard ways to convert little endian data to big endian and vice versa .
My answer:
Linux is little endian and Solaris is big endian.
After that I said Processor(CPU) decides endianness of the machine. Intel processor supports little endian and SPARCV( Solaris) processor supports big endian.
He asked what about Solaris operating system with Intel processor ?. I said it is little endian.
Am I correct ?| Report Duplicate | Flag | PURGE
Gluster Software Engineer / Developer Computer Architecture & Low Level - 0of 0 votes
Answers4) How to initialize Constant variables in class( or object).
example 1: throws error "uninitialized member 'myclass::i' with 'const' type 'const int'
"#include <iostream> using namespace std; class myclass{ public: const int i; myclass() { i = 10; // here throws error } }; int main() { myclass m; cout<<m.i<<endl; return 0; }
example 2: below piece of code works fine .
#include <iostream> using namespace std; class myclass{ public: const int i; myclass() : i(10) { } }; int main() { myclass m; cout<<m.i<<endl; return 0; }
Can some one please explain me , why second example works fine ? . why not first example ?
- siva.sai.2020 February 13, 2011| Report Duplicate | Flag | PURGE
Gluster Software Engineer / Developer C++