Entries Tagged as 'C/C++'
Basics of validating xmls with a given schema in C++.
1. Create parser instance.
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
2. Set required features to parser instance as follow.
// Enable the parser’s schema support parser->setFeature(XMLUni::fgXercesSchema, true);
// Schema validation requires namespace processing to be turned on.<br />parser->setFeature(XMLUni::fgSAX2CoreValidation,true);<br />parser->setFeature(XMLUni::fgSAX2CoreNameSpaces,true);
3. Set schema location using setPropery api call with/without namespace. If we want use […]
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags:parser·sax2·schema·validation·xerces-c·xml
Basics of validating xmls with a given schema.
1. Create parser instance.
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
2. Set required features to parser instance as follow.
// Enable the parser’s schema support
parser->setFeature(XMLUni::fgXercesSchema, true);
// Schema validation requires namespace processing to be turned on.
parser->setFeature(XMLUni::fgSAX2CoreValidation,true);
parser->setFeature(XMLUni::fgSAX2CoreNameSpaces,true);
3. Set schema location using setPropery api call with/without namespace. If we want use ‘ExternalSchemaLocation’ property we need to […]
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags:parser·sax2·schema·validation·xerces-c·xml
The source code for bubble sort.
#include
#define NUM 6
void swap(int arr[], int i, int j) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
main() {
int arr[NUM],i,j;
// start reading nums
for(i=0;i
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags:
Source code for shell sort is provided below.
#include
#define NUM 6
main() {
int arr[NUM],i,j, incr=2;
// start reading nums
for(i=0;i
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags:
Source code for Insertion sort in C language.
#include
#define NUM 6
main() {
int arr[NUM],i,j;
// start reading nums
for(i=0;i
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags:
The code for the selection sort in C lang is provided below.
#include
#define NUM 6
void swap(int arr[], int i, int j) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
main() {
int arr[NUM],i,j;
// start reading nums
for(i=0;i arr[j])
swap(arr,i,j);
// print sorted arr
for(i=0;i
Please point your web link to this page if you are using this code for any purposes.
Bookmark it!
These icons […]
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags:
A common problem asked in job interviews is to count the number of bits that are on in an unsigned integer. Here are seven solutions to this problem. Source code in C is available.
Iterated Count
int bitcount (unsigned int n)
{
int count=0;
while (n)
{
count += n & […]
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags:
Virtual Functions
Design Patterns
Important C/C++ Basic Concepts
Program startup and termination are facilitated by using two functions: main and exit. Other startup and termination code may be executed.
The arguments in the prototype
int main( int argc[ , char *argv[ ] [, char *envp[ ] ] ] );
or
int wmain( int argc[ , wchar_t *argv[ ] [, wchar_t […]
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags:
int main(int argc,char *argv[]){
int a=atoi(argv[1]),b=atoi(argv[2]),sum,carry;
sum = a^b;
carry = a&b;
while(carry){
carry = carry
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags:
Generally, a header (.h) file should have (A header file need not have a .h extension, its just a convention):
1. Macro definitions (preprocessor #defines).
2. Structure, union, and enumeration declarations.
3. Any typedef declarations.
4. External function declarations.
5. Global variable declarations.
Put declarations / definitions in header files if they will be shared between several other files. If some […]
Bookmark it!
These icons link to social bookmarking sites where readers can share and discover new web pages.
[Read more →]
Tags: