Tags » C-2

Web API: Supporting data shaping

Usually while building high availability Web API’s, where you know that typically your business objects are quite complex with a lot of properties returned as a part of the object, to the client, one would ideally like to give the client the ability to be able to request a specific number of fields. 797 more words

C#

Subtle And Quirky, But Still Lovable

I’m a long time C++ programmer who’s going to expose something embarrassing about myself. As a starting point, please take a look at the code below: 335 more words

C++

Sniptaculous, a C# snippet library

I’ve just released the first version of Sniptaculous, a Visual Studio C# snippet library.

I think the existing snippets are great. They have parameters and some of them, such as the switch snippet ( 60 more words

C#

Pyramid pattern

<br /> 

#include<iostream>
using namespace std;
int main()
{
int i,j,k,l,a;
cout<<"Enter the number of lines in the pyramid=";
cin>>a;
cout<<endl;
for(i=1;i<=a;i++)
{
for(j=a;j>=i;j--)
cout<<" ";
for(k=1;k<=i;k++)
{
cout<<"*";
}
for(l=1;l<=i-1;l++)
cout<<"*";

cout<<endl;

}
return 0;
}

 

output:

Programs

STL - Map

In fact, the STL’s map class allows you to store data by any type of key instead of simply by a numerical key, the way you must access an array or vector. 465 more words

C++

C# Variables

A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a specific type, which determines the size and layout of the variable’s memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable. 74 more words

C#

Computerized Crime Register:

<br />#include

#include
#include
#include
#include
#include using namespace std;
class project
{
public:
char crime;
char name;

void getdata()
{
cout << "\nEnter name= "; cin>>name;

cout << "Enter the crime= "; cin>>crime;
}

void showdata()
{
cout << "\nName= " << name << endl ;
cout << "crime= " << crime<<endl;
}
void writedata()
{
ofstream fout("crime.txt", ios::app | ios::out);
project obj;
obj.getdata();
fout.write((char*)&obj, sizeof(obj));
fout.close();
}
};
int main()
{
project obj;
int num, input, flag = 0;
char pname,pcrime;
lable:
system("cls");
cout << "1.Add data\n";
cout << "2.Search by name\n";
cout << "3.Search by crime\n";
cout << "4.See all data\n";
cout << "5.Exit\n";
cout << "Enter choice: "; cin >> input;
ifstream fin("crime.txt",ios::in);
switch(input)
{ //adding new data
case 1:
obj.writedata();
fin.close();
goto lable;
case 2: //searching by name
cout << "\nEnter name= "; cin>>pname;
while (fin.read((char*)&obj,sizeof(obj)))
if (strcmp(pname,obj.name)==0)
{
obj.showdata();
flag = 1;
}
fin.close();
if (flag == 0)
cout << "\n\nDATA NOT FOUND!!!";
getch();
goto lable;
case 3: //searching by crime
cout << "\nEnter crime= "; cin>>pcrime;
while (fin.read((char*)&obj, sizeof(obj)))
if (strcmp(pcrime,obj.crime)==0)
{
obj.showdata();
flag = 1;
}
fin.close();
if (flag == 0)
cout << "\n\nDATA NOT FOUND!!!";
getch();
goto lable;
case 4: //show the list of all data
cout << "\nList of data::\n";
while (fin.read((char*)&obj, sizeof(obj)))
{
obj.showdata();
cout << endl;
flag = 1;
}
fin.close();
if (flag == 0)
cout << "\n\nDATA NOT FOUND!!!";
getch();
goto lable;
case 5:
exit(0);
default:
goto lable;
}
}

output:

  

Programs