Code:
FILE *file=fopen("file.in", "rb"); BYTE buf; while(feof(file)==FALSE) { int n=fread(&buf, 1, 1, file); if(n>0) { // process here... } } fclose(file); file=NULL;
FILE *file=fopen("file.in", "rb"); BYTE buf; while(feof(file)==FALSE) { int n=fread(&buf, 1, 1, file); if(n>0) { // process here... } } fclose(file); file=NULL;
void printMyName() { cout<<"Your name here"<<endl; cout<<"Program descriptions here"<<endl; } int findLargest(int a, int b, int c) { int largest=a; if(largest<b) largest=b; if(largest<c) largest=c; return largest;
for(int i=0; i<10; i++) { for(int j=0; j<i; j++) { cout<<" "; } for(int j=i; j<10; j++) { cout<<"*"; } cout<<endl; }
// in this code i treat the input number as a string // and i assume that the input is valid (it means the input is a number // and it doesn't contant any non-numeric character... cout<<"input a number:"; char strNum[10]=""; cin>>strNum; cout<<endl; // calculate sum and mul of all figures to form the input number int sum=0; int mul=1;
void main() { cout<<"Input a character and a integer number:"<<endl; char ch; int num; cin>>ch>>num; if(num<0) num=1; if(num%2==0) num++; system("cls"); for(int i=0; i<num; i++) {
[left]int count(char ch, char str[]) { int cnt=0; [b]int len=strlen(str);[/b] [b]if(len<=0)[/b] [b]{[/b] [b]return 0;[/b] [b]}[/b] [b]else[/b] if(len==1) { if(str[0]==ch) cnt++; } else[/]
int count(char ch, char str[]) { int cnt=0; if(strlen(str)==1) { if(str[0]==ch) cnt++; } else { if(str[0]==ch) cnt++; cnt+=foo(ch, str+1); } return cnt; }
#include<iostream> int FindLowNum(int [], int ); int main() { const int arraySize = 20; int a[ arraySize ] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; int total = 0; // sum contents of array a for ( int i = 0; i < arraySize;
#include<stdio.h> void swap(int &, int &); void main(){ int num1, num2; printf("Enter 2 numbers > "); scanf("%d%d", &num1, &num2); if(num1 > num2) swap(num1, num2); printf("In ascending order: %d %d \n", num1, num2); }
#include<iostream.h> #include<conio.h> main() { [B]system("cls");[/B] int x,y,z; cout<< " input x,y \n"; cin>> x >> y; z=x+y; cout<< " z=" <<z<<"\n"; getch(); }
#include <stdio.h> #include <conio.h> #include <io.h> char* BYTE2Bin(BYTE val) { char *temp=(char*)calloc(8, sizeof(char)); for(int i=0; i<8; i++) { if(((val>>i)&0x01)==1) temp[7-i]=0x31; else temp[7-i]=0x30; } return temp; } void Encode(char *infile, char *outfile) { FILE *file=NULL;
Leave a comment: