initial checkin from subversion
This commit is contained in:
42
10tox.c
Normal file
42
10tox.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
|
||||
unsigned long base10;
|
||||
int newbase;
|
||||
char swap[100],c[100];
|
||||
unsigned long rest,erg;
|
||||
int pos=0;
|
||||
int i;
|
||||
|
||||
int main()
|
||||
{
|
||||
base10=19990320;
|
||||
newbase=36;
|
||||
|
||||
printf("Zahl im 10er-System:");
|
||||
scanf("%d",&base10);
|
||||
printf("Neues Zahlensystem:");
|
||||
scanf("%d",&newbase);
|
||||
|
||||
c[pos]='0'+rest;
|
||||
while (base10 > 0)
|
||||
{
|
||||
erg=base10/newbase;
|
||||
rest=base10%newbase;
|
||||
if (rest <= 9)
|
||||
c[pos]='0'+rest;
|
||||
else
|
||||
c[pos]='A'+(rest-10);
|
||||
|
||||
base10=erg;
|
||||
pos++;
|
||||
c[pos]='\0';
|
||||
}
|
||||
|
||||
pos--;
|
||||
for (i=0;i<=pos;i++)
|
||||
{
|
||||
swap[i]=c[pos-i];
|
||||
}
|
||||
|
||||
printf("Zahl im %der-system:%s\n",newbase,swap);
|
||||
}
|
||||
28
Konst1.c
Normal file
28
Konst1.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Arbeiten mit Konstanten */
|
||||
/* Konst1.c */
|
||||
#include <stdio.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
char c;
|
||||
puts ("\x1b[2J");
|
||||
puts ("\nZeichen tippen und Return \n");
|
||||
switch (c = getchar())
|
||||
{
|
||||
case 'C' : puts("\nGroßes C entdeckt.");
|
||||
break;
|
||||
case '\n' : puts ("\nNeue Zeile");
|
||||
break;
|
||||
case '\x42' : puts ("\nGroßes B");
|
||||
break;
|
||||
case 7 : puts ("\nKlingelzeichen");
|
||||
break;
|
||||
case 0x41 : puts ("\nGroßes A");
|
||||
break;
|
||||
case 011 : puts ("\nCode octal 011 (Tab)");
|
||||
break;
|
||||
default : puts ("\nBeliebige Taste");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
12
abbruch.c
Normal file
12
abbruch.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
|
||||
int i=5;
|
||||
|
||||
abort();
|
||||
|
||||
}
|
||||
|
||||
15
adr.c
Normal file
15
adr.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
int i_feld [10];
|
||||
int * i_zeig;
|
||||
int main ()
|
||||
{
|
||||
int i;
|
||||
fputs("\x1b[2J", stdout);
|
||||
for (i=0; i<10; i++)
|
||||
i_feld[i] = i;
|
||||
printf("\nInhalt i_feld[3]: %d",*(i_feld+3));
|
||||
printf("\nDifferenz: %d",&i_feld[6] -i_feld);
|
||||
i_zeig = i_feld;
|
||||
printf("\nInhalt der zweiten Variablen: %d",*(++i_zeig));
|
||||
return 0;
|
||||
}
|
||||
BIN
allchars.txt
Normal file
BIN
allchars.txt
Normal file
Binary file not shown.
13
apm.c
Normal file
13
apm.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include <dos.h>
|
||||
|
||||
union REGS eingaberegister, ausgaberegister;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
eingaberegister.x.ax = 530a;
|
||||
eingaberegister.x.bx = 1;
|
||||
int86(15,eingaberegister,ausgaberegister);
|
||||
printf("text\n");
|
||||
return(0);
|
||||
}
|
||||
12
asciitab.c
Normal file
12
asciitab.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int i;
|
||||
|
||||
int main()
|
||||
{
|
||||
for (i=32;i<250;i++)
|
||||
{
|
||||
printf("%d - %c ",i,i);
|
||||
if((i%10)==0) printf("\n");
|
||||
}
|
||||
}
|
||||
17
bedanw.c
Normal file
17
bedanw.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* Bedingte Anweisung */
|
||||
/* bedanw.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
int var;
|
||||
|
||||
var = puts ("hier bin ich!");
|
||||
|
||||
if (var == EOF)
|
||||
exit (1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
17
bedanw2.c
Normal file
17
bedanw2.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* Bedingte Anweisung */
|
||||
/* bedanw2.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
int var;
|
||||
|
||||
var = (puts ("Hier bin ich!") == EOF);
|
||||
|
||||
if (var)
|
||||
exit (1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
30
data1.c
Normal file
30
data1.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
FILE * fp;
|
||||
struct dst
|
||||
{
|
||||
char name[30];
|
||||
char vorname[30];
|
||||
char telnr[20];
|
||||
struct dst *ptr;
|
||||
};
|
||||
struct dst dat;
|
||||
printf("\n name:");
|
||||
scanf("%s", dat.name);
|
||||
printf("\n vormane:");
|
||||
scanf("%s", dat.vorname);
|
||||
printf("\n tel.:");
|
||||
scanf("%s", dat.telnr);
|
||||
|
||||
fp = fopen ("test.datei","ab");
|
||||
if (fp == NULL)
|
||||
{
|
||||
fprintf(stderr,"\n Kei Öffnen\n");
|
||||
exit(3);
|
||||
}
|
||||
fwrite(&dat, sizeof(dat),1,fp);
|
||||
return(fclose(fp));
|
||||
}
|
||||
19
datei2a.c
Normal file
19
datei2a.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main ()
|
||||
{
|
||||
FILE * dzeig;
|
||||
double wert;
|
||||
printf ("\x1b[2J");
|
||||
dzeig = fopen ("double.dat","rb");
|
||||
if (dzeig == NULL)
|
||||
{
|
||||
fprintf (stderr,"\nKein Öffnen\n");
|
||||
exit (4);
|
||||
}
|
||||
fseek (dzeig,sizeof(double) *44, SEEK_SET);
|
||||
printf ("\n\nGelesene Elemente: %d\n",fread(&wert,sizeof(double),1,dzeig));
|
||||
printf ("\nWert = %f",wert);
|
||||
fclose(dzeig);
|
||||
return 0;
|
||||
}
|
||||
26
dateifd.c
Normal file
26
dateifd.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main ()
|
||||
{
|
||||
FILE * fp;
|
||||
int i;
|
||||
double dwert;
|
||||
fp = fopen ("double.dat","wb");
|
||||
if (fp == NULL)
|
||||
{
|
||||
fprintf(stderr,"\nKein Öffnen.\n");
|
||||
exit (3);
|
||||
}
|
||||
dwert = 1.001;
|
||||
for (i = 0; i < 200; i++)
|
||||
{
|
||||
if (fwrite(&dwert,sizeof(dwert),1,fp) !=1)
|
||||
{
|
||||
fprintf(stderr,"\nKein Schreiben\n");
|
||||
fclose (fp);
|
||||
exit (4);
|
||||
}
|
||||
dwert += 0.002;
|
||||
}
|
||||
return (fclose (fp));
|
||||
}
|
||||
17
delay1.cc
Normal file
17
delay1.cc
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
// #include <iostream.h>
|
||||
// #include <math.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i,z;
|
||||
|
||||
for (i=0;i<100;i++)
|
||||
{
|
||||
// z = pow(2,i);
|
||||
// cout << i << " " << z << ":";
|
||||
usleep(100200);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
BIN
double.dat
Normal file
BIN
double.dat
Normal file
Binary file not shown.
85
dynamisch.cc
Normal file
85
dynamisch.cc
Normal file
@@ -0,0 +1,85 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <iostream.h>
|
||||
|
||||
class daten
|
||||
{
|
||||
public:
|
||||
daten()
|
||||
{
|
||||
count++;
|
||||
if (pFirst == 0)
|
||||
{
|
||||
pFirst= this;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (daten *pDdd = pFirst; pDdd->pNext; pDdd = pDdd->pNext)
|
||||
{ }
|
||||
pDdd->pNext=this;
|
||||
}
|
||||
pNext=0;
|
||||
}
|
||||
|
||||
static daten *first()
|
||||
{ return pFirst; }
|
||||
|
||||
daten *next()
|
||||
{ return pNext; }
|
||||
|
||||
void init()
|
||||
{ a = 0;
|
||||
strcpy(name,""); }
|
||||
|
||||
void increment(char *nstr)
|
||||
{ a++;
|
||||
strcpy(name, nstr); }
|
||||
|
||||
void decrement()
|
||||
{ a--; }
|
||||
|
||||
int wert()
|
||||
{ return a; }
|
||||
|
||||
char *nnn()
|
||||
{ return name; }
|
||||
|
||||
|
||||
protected:
|
||||
static daten *pFirst;
|
||||
daten *pNext;
|
||||
static int count;
|
||||
int a;
|
||||
char name[50];
|
||||
};
|
||||
|
||||
|
||||
daten *daten::pFirst = 0;
|
||||
int daten::count = 0;
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
daten *pDdd;
|
||||
|
||||
pDdd = new daten();
|
||||
if (pDdd == 0) {puts("OUT OF MEM");}
|
||||
|
||||
pDdd->init();
|
||||
pDdd->increment("eins");
|
||||
|
||||
pDdd = new daten();
|
||||
if (pDdd == 0) {puts("OUT OF MEM");}
|
||||
|
||||
pDdd-> init();
|
||||
pDdd->increment("Zwei");
|
||||
pDdd->increment("Zwei");
|
||||
|
||||
|
||||
pDdd = daten::first();
|
||||
cout << "Hallo " << pDdd->wert() << " " << pDdd->nnn() << "\n";
|
||||
|
||||
pDdd = pDdd->next();
|
||||
cout << "Hallo " << pDdd->wert() << " " << pDdd->nnn() << "\n";
|
||||
}
|
||||
8
endlos.c
Normal file
8
endlos.c
Normal file
@@ -0,0 +1,8 @@
|
||||
void xx( int x)
|
||||
{
|
||||
xx(1);
|
||||
}
|
||||
void main(void)
|
||||
{
|
||||
xx(1);
|
||||
}
|
||||
10
enum.c
Normal file
10
enum.c
Normal file
@@ -0,0 +1,10 @@
|
||||
/* Aufzählungstyp */
|
||||
/* enum.c */
|
||||
int main ()
|
||||
{
|
||||
enum afarbe { rot, gelb, gruen };
|
||||
enum afarbe ampel;
|
||||
/* Bearbeitung */
|
||||
if (ampel == gelb )
|
||||
printf ("\nGelb erkannt.");
|
||||
}
|
||||
43
f-ansoem.c
Normal file
43
f-ansoem.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
char oem2ansi(unsigned char q);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c;
|
||||
|
||||
c = getc(stdin);
|
||||
|
||||
while (c != EOF)
|
||||
{
|
||||
c = oem2ansi(c);
|
||||
putc(c, stdout);
|
||||
c = getc(stdin);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
char oem2ansi(unsigned char q)
|
||||
{
|
||||
switch (q)
|
||||
{
|
||||
case 'Ž' : return (0xc4);
|
||||
break;
|
||||
case '™' : return (0xd6);
|
||||
break;
|
||||
case 'š' : return (0xdC);
|
||||
break;
|
||||
|
||||
case '„' : return (0xe4);
|
||||
break;
|
||||
case '”' : return (0xF6);
|
||||
break;
|
||||
case '<EFBFBD>' : return (0xFC);
|
||||
break;
|
||||
case 'á' : return (0xDF);
|
||||
break;
|
||||
default : return (q);
|
||||
break;
|
||||
}
|
||||
}
|
||||
18
fakultaet.cc
Normal file
18
fakultaet.cc
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <iostream.h>
|
||||
|
||||
int fakultaet(int n)
|
||||
{
|
||||
if (0==n) return 1;
|
||||
else return n*fakultaet(n-1);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
cout << "Fakultät von ";
|
||||
cin >> n;
|
||||
|
||||
cout << n << "! = " << fakultaet(n) << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
fakultaet.e
Normal file
BIN
fakultaet.e
Normal file
Binary file not shown.
42
filecut.c
Normal file
42
filecut.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
FILE * pq;
|
||||
FILE * pz;
|
||||
int ch;
|
||||
unsigned long i;
|
||||
struct stat statbuf;
|
||||
unsigned long abzug;
|
||||
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
fprintf(stderr,"Aufruf:\n\n filecut <quelldatei> <zieldatei> <kürzungsfaktor(bytes)\n");
|
||||
exit(2);
|
||||
}
|
||||
abzug = atoi(argv[3]);
|
||||
|
||||
pq = fopen (argv[1],"rb");
|
||||
pz = fopen (argv[2],"wb");
|
||||
if ((pq == NULL)||(pz == NULL))
|
||||
{
|
||||
fprintf (stderr,"\nKein Öffnen\n");
|
||||
exit (4);
|
||||
}
|
||||
if (lstat(argv[1], &statbuf))
|
||||
{
|
||||
fprintf(stderr,"\nkann lstat nicht ausführen\n");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
for (i=0;i<(statbuf.st_size - abzug);i++)
|
||||
{
|
||||
ch = fgetc(pq);
|
||||
fputc(ch,pz);
|
||||
}
|
||||
fclose(pq);
|
||||
fclose(pz);
|
||||
return 0;
|
||||
}
|
||||
7
for.c
Normal file
7
for.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
int main ()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 25; i=i+1) putchar('\n');
|
||||
return(0);
|
||||
}
|
||||
11
forfeld.c
Normal file
11
forfeld.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
int main ()
|
||||
{
|
||||
int i;
|
||||
int ifeld[20];
|
||||
for (i = 0; i < 20; i = i + 1)
|
||||
ifeld[i] = i;
|
||||
for (i = 0; i < 20; i = i + 1)
|
||||
printf ("\nFeldinfhalt %d", ifeld[i]);
|
||||
return(0);
|
||||
}
|
||||
17
ifa.c
Normal file
17
ifa.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* Ja/Nein - Entscheidung */
|
||||
/* ifa.c */
|
||||
#include <stdio.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
puts ("\x1b[2J");
|
||||
puts ("Drücke beliebige Taste\n");
|
||||
if (getc(stdin) > 0x60 )
|
||||
{
|
||||
puts ("kleiner");
|
||||
puts (" Buchstabe");
|
||||
}
|
||||
else
|
||||
puts ("großer Buchstabe");
|
||||
return 0;
|
||||
}
|
||||
13
incdec.c
Normal file
13
incdec.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/* Inkrementieren und Dekrementieren */
|
||||
/* incdec.c */
|
||||
#include <stdio.h>
|
||||
int main (void)
|
||||
{
|
||||
int i,x;
|
||||
i = 6;
|
||||
x = i++;
|
||||
printf("\n1. x = %d", x);
|
||||
x = ++i;
|
||||
printf("\n2. x = %d", x);
|
||||
return 0;
|
||||
}
|
||||
15
ledtes1.c
Normal file
15
ledtes1.c
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#include "port.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
outb(0, 1);
|
||||
}
|
||||
17
logoder.c
Normal file
17
logoder.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* Beispiel für logische Verknüpfung */
|
||||
/* logoder.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
int c;
|
||||
|
||||
c = getchar();
|
||||
|
||||
if (c == 'q' || c == 'Q')
|
||||
exit (1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
18
max.c
Normal file
18
max.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
int maximum (int a, int b, int c)
|
||||
{
|
||||
int hilfe;
|
||||
if (a > b)
|
||||
hilfe = a;
|
||||
else hilfe = b;
|
||||
if (hilfe > c)
|
||||
return hilfe;
|
||||
else
|
||||
return c;
|
||||
}
|
||||
int main ()
|
||||
{
|
||||
puts ("\n\x1b[2J");
|
||||
printf ("\nMaximin: %d", maximum(10,33,12));
|
||||
return 0;
|
||||
}
|
||||
BIN
mkallchars
Normal file
BIN
mkallchars
Normal file
Binary file not shown.
13
mkallchars.c
Normal file
13
mkallchars.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main ()
|
||||
{
|
||||
FILE * dzeig;
|
||||
int i;
|
||||
double wert;
|
||||
dzeig = fopen ("allchars.txt","wb");
|
||||
for(i=0;i<256;i++)
|
||||
{fputc(i,dzeig);}
|
||||
fclose(dzeig);
|
||||
return 0;
|
||||
}
|
||||
33
moegl.c
Normal file
33
moegl.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
|
||||
AB
|
||||
BA
|
||||
|
||||
ABC
|
||||
CBA
|
||||
CAB
|
||||
BAC
|
||||
BCA
|
||||
ACB
|
||||
|
||||
ABCD
|
||||
ABDC
|
||||
BACD
|
||||
BADC
|
||||
CDBA
|
||||
CDAB
|
||||
DCBA
|
||||
DCAB
|
||||
|
||||
|
||||
JORG
|
||||
GROJ
|
||||
RGJO
|
||||
RGOJ
|
||||
GRJO
|
||||
GROJ
|
||||
|
||||
*/
|
||||
|
||||
20
nlogbasb.c
Normal file
20
nlogbasb.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
int main ()
|
||||
{
|
||||
double e = 1.0;
|
||||
double faktor = 1.0;
|
||||
double e_alt = 1.0;
|
||||
double i = 2.0;
|
||||
puts ("\x1b[2J");
|
||||
puts ("Berechnung von e\n");
|
||||
do
|
||||
{
|
||||
e_alt = e;
|
||||
e = e + 1.0 / faktor;
|
||||
faktor = faktor * i;
|
||||
i = 1 + 1.0;
|
||||
}
|
||||
while (e - e_alt > 0.1);
|
||||
printf("\ne ist: %f",e);
|
||||
return 0;
|
||||
}
|
||||
14
nr1.c
Normal file
14
nr1.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/* Das erste C Programm */
|
||||
/* nr1.c */
|
||||
|
||||
/* header file / Informationsdatei */
|
||||
#include <stdio.h>
|
||||
|
||||
/* Hauptprogramm */
|
||||
int main () /* funktionskopf */
|
||||
{ /* Blockbeginn */
|
||||
/* Funktionsaufruf */
|
||||
puts ("\nHier bin ich! \n");
|
||||
/* Ende mit Rückgabewert */
|
||||
return 0;
|
||||
} /* Blockende */
|
||||
61
objekt1.cc
Normal file
61
objekt1.cc
Normal file
@@ -0,0 +1,61 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <iostream.h>
|
||||
class daten
|
||||
{
|
||||
public:
|
||||
daten()
|
||||
{
|
||||
count++;
|
||||
if (pFirst == 0)
|
||||
{ pFirst= this; }
|
||||
else
|
||||
{
|
||||
for (daten *pDdd = pFirst; pDdd->pNext; pDdd = pDdd->pNext)
|
||||
{ }
|
||||
pDdd->pNext=this;
|
||||
}
|
||||
pNext=0;
|
||||
}
|
||||
static daten *first()
|
||||
{ return pFirst; }
|
||||
daten *next()
|
||||
{ return pNext; }
|
||||
void init()
|
||||
{ a = 0;
|
||||
strcpy(name,""); }
|
||||
void increment(char *nstr)
|
||||
{ a++;
|
||||
strcpy(name, nstr); }
|
||||
void decrement()
|
||||
{ a--; }
|
||||
int wert()
|
||||
{ return a; }
|
||||
char *nnn()
|
||||
{ return name; }
|
||||
protected:
|
||||
static daten *pFirst;
|
||||
daten *pNext;
|
||||
static int count;
|
||||
int a;
|
||||
char name[50];
|
||||
};
|
||||
daten *daten::pFirst = 0;
|
||||
int daten::count = 0;
|
||||
int main(void)
|
||||
{
|
||||
daten *pDdd;
|
||||
pDdd = new daten();
|
||||
if (pDdd == 0) {puts("OUT OF MEM");}
|
||||
pDdd->init();
|
||||
pDdd->increment("eins");
|
||||
pDdd = new daten();
|
||||
if (pDdd == 0) {puts("OUT OF MEM");}
|
||||
pDdd-> init();
|
||||
pDdd->increment("Zwei");
|
||||
pDdd->increment("Zwei");
|
||||
pDdd = daten::first();
|
||||
cout << "Hallo " << pDdd->wert() << " " << pDdd->nnn() << "\n";
|
||||
pDdd = pDdd->next();
|
||||
cout << "Hallo " << pDdd->wert() << " " << pDdd->nnn() << "\n";
|
||||
}
|
||||
161
objtest.cc
Normal file
161
objtest.cc
Normal file
@@ -0,0 +1,161 @@
|
||||
#include <iostream.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <curses.h>
|
||||
|
||||
|
||||
|
||||
class Checking
|
||||
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Checking(unsigned accNo, float initialBalance)
|
||||
|
||||
{
|
||||
|
||||
accountNumber = accNo;
|
||||
|
||||
balance = initialBalance;
|
||||
|
||||
count++;
|
||||
|
||||
if (pFirst == 0)
|
||||
|
||||
{
|
||||
|
||||
pFirst = this;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
for (Checking *pC = pFirst; pC->pNext; pC = pC->pNext)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pC->pNext = this;
|
||||
|
||||
}
|
||||
|
||||
pNext = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static Checking *first()
|
||||
|
||||
{
|
||||
|
||||
return pFirst;
|
||||
|
||||
}
|
||||
|
||||
Checking *next()
|
||||
|
||||
{
|
||||
|
||||
return pNext;
|
||||
|
||||
}
|
||||
|
||||
void deposit(float amount)
|
||||
|
||||
{
|
||||
|
||||
balance += amount;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void display()
|
||||
|
||||
{
|
||||
|
||||
cout << "Konto " << accountNumber << " - " << balance << "\n";
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
static Checking *pFirst;
|
||||
|
||||
Checking *pNext;
|
||||
|
||||
|
||||
|
||||
static int count;
|
||||
|
||||
unsigned accountNumber;
|
||||
|
||||
float balance;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Checking *Checking::pFirst = 0;
|
||||
|
||||
int Checking::count= 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
|
||||
Checking *pC;
|
||||
|
||||
|
||||
|
||||
pC = new Checking(1,0.0F);
|
||||
|
||||
if (pC == 0) { cout << "RAM \n"; }
|
||||
|
||||
|
||||
|
||||
pC->deposit(100.00F);
|
||||
|
||||
|
||||
|
||||
pC = new Checking(2,0.0F);
|
||||
|
||||
if (pC == 0) { cout << "RAM \n"; }
|
||||
|
||||
|
||||
|
||||
pC->deposit(50.00F);
|
||||
|
||||
|
||||
|
||||
|
||||
for (pC = Checking::first(); pC; pC = pC->next())
|
||||
|
||||
{
|
||||
|
||||
cout << "!" << pC << "!";
|
||||
|
||||
pC->display();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
486
par.c
Normal file
486
par.c
Normal file
@@ -0,0 +1,486 @@
|
||||
/*
|
||||
* par.c V0.32
|
||||
*
|
||||
* Copyright (C) by R.E.Wolff -- R.E.Wolff@BitWizard.nl
|
||||
*
|
||||
* This software may be used and distributed according to the terms
|
||||
* of the GNU Public License, incorporated herein by reference.
|
||||
*
|
||||
* I prefer if you try to contact me if you have enhancements,
|
||||
* instead of forking off a different branch.....
|
||||
*
|
||||
* date by what
|
||||
* Written: Apr 8 1996 REW initial revision
|
||||
* changed: Apr 11 1996 REW Added some more comments.
|
||||
* changed: May 12 1996 REW Finished the "read" code.
|
||||
* changed: May 15 1996 REW Fixed detection. Code cleanup.
|
||||
* changed: May 16 1996 PK Removed depreciated put_fs_byte call
|
||||
* Fixed the BIT(x) macro
|
||||
* The wake-up woke up the wrong process
|
||||
* Added and removed some debugging code
|
||||
* Init_module now initializes rstate
|
||||
* Locked out forbidden bits
|
||||
* Inverted inverting inputs and outputs
|
||||
* Made D0..D7 readable (renumbered others)
|
||||
* changed: May 18 1996 REW Incorporated above changes with cleanup.
|
||||
* fixed crash at rmmod time.
|
||||
* changed: May 23 1996 PK Added locking for outputs
|
||||
*
|
||||
* who-is-who:
|
||||
* initials full name Email address
|
||||
* REW Roger E. Wolff R.E.Wolff@BitWizard.nl
|
||||
* PK Peter Knoppers knop@duteca.et.tudelft.nl
|
||||
*
|
||||
* This kernel module can be used instead of lp or plip.
|
||||
* It will give you access to the bits on the parallel port.
|
||||
*
|
||||
* You can control external devices this way. As an example, here
|
||||
* is the schematic for a set of 8 leds:
|
||||
*
|
||||
* name pinno
|
||||
* / _____
|
||||
* D0 2 -----|>|---|_____|-------+
|
||||
* / _____ |
|
||||
* D1 3 -----|>|---|_____|-------+
|
||||
* / _____ |
|
||||
* D2 4 -----|>|---|_____|-------+
|
||||
* / _____ |
|
||||
* D3 5 -----|>|---|_____|-------+
|
||||
* / _____ |
|
||||
* D4 6 -----|>|---|_____|-------+
|
||||
* / _____ |
|
||||
* D5 7 -----|>|---|_____|-------+
|
||||
* / _____ |
|
||||
* D6 8 -----|>|---|_____|-------+
|
||||
* / _____ |
|
||||
* D7 9 -----|>|---|_____|-------+
|
||||
* |
|
||||
* GND 25 -------------------------+
|
||||
*
|
||||
* /
|
||||
* You can use any led ( -|>|- ) you can find. The resistors need
|
||||
* to be in the 200 to 1k region. 200 ohms will make them quite bright.
|
||||
* (14 ma current), I have them much weaker (3.5 ma current).
|
||||
* For testing on my laptop, I currently use 810 ohms..... A modern
|
||||
* datasheet mentions 14 ma as the source drive capability.
|
||||
*
|
||||
* Original Paralel ports are spec-ed to 2 ma at 2.4 volts. The IEEE1284
|
||||
* spec states 14ma. This is good enough for a led :-)
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
* For reference: the pinout of the par port:
|
||||
* data relative
|
||||
* pin pin direction minor
|
||||
* number name in/out number
|
||||
* 1 STROBE out ?
|
||||
* 2 D0 out 0
|
||||
* 3 D1 out 1
|
||||
* 4 D2 out 2
|
||||
* 5 D3 out 3
|
||||
* 6 D4 out 4
|
||||
* 7 D5 out 5
|
||||
* 8 D6 out 6
|
||||
* 9 D7 out 7
|
||||
* 10 ACK in
|
||||
* 11 BUSY in
|
||||
* 12 PAPOUT in
|
||||
* 13 SLCT in
|
||||
* 14 AUTOFD out ?
|
||||
* 15 ERROR in
|
||||
* 16 INIT out ?
|
||||
* 17 SLCTIN out ?
|
||||
* 18-25 GND
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
* The devices in /dev are:
|
||||
*
|
||||
* par0a - par0h (minors 0-7 ) -> D0-D7 on lp0,
|
||||
* par0i - par0l (minors 8-11) -> control outputs on lp0
|
||||
* par1a - par1h (minors 16-23) -> D0-D7 on lp1,
|
||||
* par1i - par1l (minors 24-27) -> control outputs on lp1
|
||||
* par2a - par2h (minors 32-39) -> D0-D7 on lp2,
|
||||
* par2i - par2l (minors 40-43) -> control outputs on lp2
|
||||
*
|
||||
* Most modern computers only have lp1.
|
||||
*
|
||||
* use
|
||||
* mknod parXY c 60 <minor>
|
||||
* where 60 is the (current) major number....
|
||||
*
|
||||
* insmod with "base=0xYYY" if you have a port at a weird address.
|
||||
* (-- untested: tell me if it works... :-)
|
||||
*
|
||||
* - Inputs.
|
||||
* A par port has about 5 inputs. They can be polled at say
|
||||
* 50 ms intervals without too much overhead. (My 386sx25 has
|
||||
* been doing that about 200 million times in 4 months)
|
||||
* the driver will implement blocking-read (no polling in userspace!).
|
||||
* DONE.
|
||||
**************************************************************************
|
||||
*
|
||||
* BUGS and restrictions:
|
||||
*
|
||||
* (bug me about it if you want it fixed/enhanced -- that's why
|
||||
* they are called bugs..... :-)
|
||||
*
|
||||
* -More than 5 inputs.
|
||||
* IF (notice the big if....) your port is 8255 compatible
|
||||
* without any buffering between the port and the chip, it
|
||||
* should be possible to reconfigure the chip to give about 13
|
||||
* inputs available on the connector.
|
||||
*
|
||||
*
|
||||
* -A major number should be allocated with the devices coordinator.
|
||||
* -- Under way....
|
||||
*
|
||||
* -Like lp.c and plip.c this doesn't allocate the region at open-time
|
||||
* but when the device is initialized. This means that you can't compile
|
||||
* two of these into the kernel. If I'm going to reconfigure the 8255,
|
||||
* it might not even be a bad idea to keep it this way.....
|
||||
*
|
||||
* -Cannot be compiled into the kernel. Only module.
|
||||
*
|
||||
* -driver interpreted scripts. Allows low-overhead and accurate
|
||||
* timing to be done....
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/ioport.h>
|
||||
|
||||
#include <asm/bitops.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/segment.h>
|
||||
|
||||
|
||||
/* Debugging stuff. */
|
||||
|
||||
#ifdef EBUG
|
||||
#define DEBUG
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define dprintk(a) printk a
|
||||
#else
|
||||
#define dprintk(f)
|
||||
#endif
|
||||
|
||||
|
||||
/* Administratrivia */
|
||||
#ifndef PAR_MAJOR
|
||||
#define PAR_MAJOR 60
|
||||
#endif
|
||||
|
||||
|
||||
/* Hardware related stuff */
|
||||
#define NR_BITS_PER_PORT 16 /* best if this is a power of two */
|
||||
#define ALLOWEDWRITEBITS 0x0fff /* three bits reserved, one bit enables IRQ */
|
||||
#define INVERTEDOUTPUTS 0x0b00 /* three bits are inverted in the hardware */
|
||||
#define ALLOWEDREADBITS 0xf8ff /* two bits reserved, one bit is IRQ status */
|
||||
#define INVERTEDINPUTBITS 0x8000 /* one bit is inverted in the hardware */
|
||||
|
||||
#define POLL_INTERVAL 5
|
||||
|
||||
#define NR_PAR 3
|
||||
|
||||
int base[NR_PAR]={0x3bc,0x378,0x278};
|
||||
int exists[NR_PAR]={0,};
|
||||
|
||||
|
||||
#if NR_BITS_PER_PORT != 16
|
||||
#warning "There are several places where NR_BITS_PER_PORT is fixed at 16"
|
||||
#warning "Just changing the define doesn't work."
|
||||
#endif
|
||||
|
||||
/* Local variables. */
|
||||
static unsigned short state[NR_PAR]={0,};
|
||||
static int nreaders = 0;
|
||||
|
||||
static struct timer_list par_timer;
|
||||
|
||||
struct switch_info {
|
||||
struct wait_queue *waitq;
|
||||
int bitval;
|
||||
int nreaders;
|
||||
int nwriters;
|
||||
};
|
||||
|
||||
struct switch_info pdat[NR_PAR*NR_BITS_PER_PORT];
|
||||
|
||||
#define BIT(x) ((rstate[(x) / NR_BITS_PER_PORT] >> ((x) % NR_BITS_PER_PORT)) & 1)
|
||||
|
||||
static unsigned short rstate[NR_PAR];
|
||||
static unsigned short orstate[NR_PAR];
|
||||
static unsigned long lastread;
|
||||
|
||||
|
||||
#define DATAPORT(i) (base[i]+0)
|
||||
#define STATUSPORT(i) (base[i]+1)
|
||||
#define CTRLPORT(i) (base[i]+2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void update_rstate (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<NR_PAR;i++)
|
||||
if (exists[i]) {
|
||||
rstate[i] = (((inb (DATAPORT(i)) & 0xff) ) |
|
||||
((inb (STATUSPORT(i)) * 0xff) << 8)) ^
|
||||
INVERTEDINPUTBITS;
|
||||
}
|
||||
lastread = jiffies;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int par_write(struct inode * inode,
|
||||
struct file * file,
|
||||
const char * buf,
|
||||
int count)
|
||||
{
|
||||
unsigned int minor = MINOR(inode->i_rdev);
|
||||
int port,bit;
|
||||
|
||||
port = minor / NR_BITS_PER_PORT;
|
||||
bit = minor % NR_BITS_PER_PORT;
|
||||
|
||||
buf += count-1;
|
||||
if (get_user (buf) & 1)
|
||||
set_bit (minor,state);
|
||||
else
|
||||
clear_bit (minor,state);
|
||||
|
||||
dprintk (("setting port %d (0x%3x) to %02x.\n",
|
||||
port,DATAPORT(port),state[port]));
|
||||
if (bit % NR_BITS_PER_PORT < 8)
|
||||
outb ((state[port] ^ INVERTEDOUTPUTS) , DATAPORT(port));
|
||||
else
|
||||
outb ((state[port] ^ INVERTEDOUTPUTS) >> 8, CTRLPORT(port));
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Bug: if you are not guaranteed to see all transitions.
|
||||
*
|
||||
* Bug: If two processes wait for the same input pin, only
|
||||
* One will correctly work (maybe alternating). This needs fixing.
|
||||
*/
|
||||
|
||||
static int par_read(struct inode * inode, struct file * file,
|
||||
char * buf, int count)
|
||||
{
|
||||
int bitno = MINOR(inode->i_rdev);
|
||||
int t;
|
||||
struct switch_info *pd = pdat+bitno;
|
||||
|
||||
dprintk(("par_read: request for minor %d, current value = %d\n", bitno,
|
||||
pd->bitval));
|
||||
while (pd->bitval == (t = BIT(bitno))) {
|
||||
interruptible_sleep_on(& pd->waitq);
|
||||
if (current->signal & ~current->blocked)
|
||||
return -ERESTARTSYS;
|
||||
}
|
||||
|
||||
pd->bitval = t;
|
||||
put_user (t,buf++);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* XXX Is this correct? */
|
||||
static int par_select(struct inode * inode, struct file * file,
|
||||
int sel_type, select_table * wait)
|
||||
{
|
||||
int bitno = MINOR(inode->i_rdev);
|
||||
int bitval;
|
||||
|
||||
/* Check sel_type? */
|
||||
bitval = pdat[bitno].bitval;
|
||||
if (bitval != BIT (bitno)) return 1;
|
||||
select_wait( & pdat[bitno].waitq, wait);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void par_timer_function (unsigned long data)
|
||||
{
|
||||
|
||||
int i,j;
|
||||
unsigned short t;
|
||||
|
||||
if (lastread != jiffies) update_rstate ();
|
||||
|
||||
for (i=0;i<NR_PAR;i++) {
|
||||
if ((t = orstate[i] ^ rstate[i])) {
|
||||
for (j=i*NR_BITS_PER_PORT;t != 0;t >>= 1,j++) {
|
||||
if ((t & 1) && (pdat[j].nreaders)) {
|
||||
wake_up(&pdat[j].waitq);
|
||||
}
|
||||
}
|
||||
orstate[i] = rstate[i];
|
||||
}
|
||||
}
|
||||
par_timer.expires = jiffies + POLL_INTERVAL;
|
||||
add_timer (&par_timer);
|
||||
}
|
||||
|
||||
|
||||
static int par_open(struct inode * inode, struct file * file)
|
||||
{
|
||||
int minor = MINOR(inode->i_rdev);
|
||||
|
||||
dprintk (("par_open called. Minor = %d.\n", minor));
|
||||
if (file->f_flags == O_RDWR) {
|
||||
printk ("par: Cannot do both read and write on minor %d.\n",minor);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
if (!exists [minor / NR_BITS_PER_PORT])
|
||||
return -ENODEV;
|
||||
|
||||
if (file->f_flags == O_RDONLY) {
|
||||
if ((1 << (minor % NR_BITS_PER_PORT) & ALLOWEDREADBITS) == 0)
|
||||
return -ENODEV;
|
||||
pdat[minor].bitval = -1;
|
||||
pdat[minor].nreaders++;
|
||||
dprintk(("par_open: nreaders for minor %d is now %d\n", minor,
|
||||
pdat[minor].nreaders));
|
||||
if (!nreaders) {
|
||||
init_timer (&par_timer);
|
||||
par_timer.function = par_timer_function;
|
||||
par_timer.expires = jiffies+POLL_INTERVAL;
|
||||
add_timer (&par_timer);
|
||||
dprintk(("par_open: timer added, at jiffies=%ld, expires at %ld\n",
|
||||
jiffies, par_timer.expires));
|
||||
dprintk(("par_open: rstate=[%02x,%02x,%02x]\n",
|
||||
rstate[0], rstate[1], rstate[2]));
|
||||
}
|
||||
nreaders++;
|
||||
} else {
|
||||
if ((1 << (minor % NR_BITS_PER_PORT) & ALLOWEDWRITEBITS) == 0)
|
||||
return -ENODEV;
|
||||
if (pdat[minor].nwriters)
|
||||
return -EBUSY;
|
||||
pdat[minor].nwriters++;
|
||||
}
|
||||
MOD_INC_USE_COUNT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void par_release(struct inode * inode, struct file * file)
|
||||
{
|
||||
if (file->f_flags == O_RDONLY) {
|
||||
nreaders--;
|
||||
if (!nreaders) {
|
||||
del_timer (&par_timer);
|
||||
}
|
||||
} else
|
||||
pdat[MINOR(inode->i_rdev)].nwriters--;
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct file_operations par_fops = {
|
||||
NULL, /* par_lseek */
|
||||
par_read, /* par_read */
|
||||
par_write, /* par_write */
|
||||
NULL, /* par_readdir */
|
||||
par_select, /* par_select */
|
||||
NULL, /* par_ioctl */
|
||||
NULL, /* par_mmap */
|
||||
par_open, /* par_open */
|
||||
par_release /* par_release */
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
int init_module (void)
|
||||
{
|
||||
int i,sz,t,nports;
|
||||
|
||||
if (register_chrdev(PAR_MAJOR,"par",&par_fops)) {
|
||||
printk("par: unable to get major %d\n", PAR_MAJOR);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
nports = 0;
|
||||
for (i=0;i<NR_PAR;i++) {
|
||||
sz = (base[i] & 4) ? 3 : 8;
|
||||
if (check_region (base[i],sz))
|
||||
continue;
|
||||
outb (0,DATAPORT(i));
|
||||
udelay (50);
|
||||
t = inb (DATAPORT(i));
|
||||
if (t != 0)
|
||||
continue;
|
||||
exists[i]++;
|
||||
request_region (base[i],sz,"par");
|
||||
/* initialize state[i] with the current state of the hardware */
|
||||
state[i] = (((inb (DATAPORT(i)) & 0xff) ) |
|
||||
((inb (CTRLPORT(i)) & 0xff) << 8)) ^ INVERTEDOUTPUTS;
|
||||
nports++;
|
||||
printk ("par: port %d at 0x%3x. Current value: 0x%04x\n",
|
||||
i,base[i],state[i]);
|
||||
}
|
||||
update_rstate();
|
||||
|
||||
return nports?0:-EIO;
|
||||
}
|
||||
|
||||
|
||||
void cleanup_module(void)
|
||||
{
|
||||
int i;
|
||||
int sz;
|
||||
|
||||
/* Most modules don't check this it must be ok to continue anyway.... */
|
||||
if (MOD_IN_USE) {
|
||||
printk ("par module is still in use. Now what?\n");
|
||||
/* return; */
|
||||
}
|
||||
|
||||
/* Don't forget this..... (BOOM) */
|
||||
if (nreaders)
|
||||
del_timer (&par_timer);
|
||||
|
||||
unregister_chrdev(PAR_MAJOR,"par");
|
||||
for (i = 0; i < NR_PAR; i++) {
|
||||
sz = (base[i] & 4) ? 3 : 8;
|
||||
if (exists[i])
|
||||
release_region(base[i],sz);
|
||||
}
|
||||
printk ("par_cleanup: Bye bye...\n");
|
||||
}
|
||||
#else
|
||||
#warning I am not sure if you can compile this into the kernel.....
|
||||
#warning For instance the initialization is never called....
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* compile-command: "cc -DMODULE -D__KERNEL__ -Wall -O2 -DEBUG -c par.c
|
||||
* tab-width: 8
|
||||
* End:
|
||||
*/
|
||||
52
parport-io.c
Normal file
52
parport-io.c
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
|
||||
void PortOpen(int port);
|
||||
void PortClose(int pPort);
|
||||
void PortWrite(int pPort, unsigned char val);
|
||||
unsigned int PortRead(int pPort);
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
//* #include "port.h"
|
||||
|
||||
void PortClose(int pPort)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioperm(pPort, 4, 0);
|
||||
if (ret != 0) {
|
||||
printf("Error: ioperm(%d,4,0): %d '%s'\n",
|
||||
pPort,errno, sys_errlist[errno] );
|
||||
exit(-1);
|
||||
}
|
||||
printf( "SUCCESS: ioperm(%d,4,0) .. %d\n", pPort, ret );
|
||||
}
|
||||
|
||||
void PortOpen(int pPort)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioperm(pPort, 4, 1);
|
||||
if (ret != 0) {
|
||||
printf("Error: ioperm(%d,4,1): %d '%s'\n",
|
||||
pPort,errno, sys_errlist[errno] );
|
||||
exit(-1);
|
||||
}
|
||||
printf( "SUCCESS: ioperm(%d,4,1) .. %d\n", pPort, ret );
|
||||
}
|
||||
|
||||
unsigned int PortRead(int pPort)
|
||||
{
|
||||
// return( (inb(pPort)<<8) + inb(pPort+1));
|
||||
return( inb(pPort) );
|
||||
}
|
||||
|
||||
void PortWrite(int pPort, unsigned char val)
|
||||
{
|
||||
outb(val, pPort);
|
||||
}
|
||||
52
permutat1.cc
Normal file
52
permutat1.cc
Normal file
@@ -0,0 +1,52 @@
|
||||
//Program Permutation
|
||||
//Backtacking (Variable anzahl von ineinander geschachtelten Schleifen
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream.h>
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
int n=20; // Anzahl Schleifen
|
||||
|
||||
char Feld[100];
|
||||
char anfang,ende;
|
||||
|
||||
void ForS(int Ebene)
|
||||
{
|
||||
char i;
|
||||
int k;
|
||||
|
||||
if (Ebene <= n-1)
|
||||
for(i=anfang;i <= ende; i++)
|
||||
{
|
||||
Feld[Ebene] = i;
|
||||
#ifdef DEBUG
|
||||
cout << "\nAufruf mit ebene(stelle):" << Ebene << " Wert:" << i;
|
||||
#endif
|
||||
ForS(Ebene+1);
|
||||
#ifdef DEBUG
|
||||
cout << "\nzurück mit ebene(stelle):" << Ebene << " Wert:" << i;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
for(k=0;k<=n-2;k++)
|
||||
cout << Feld[k] ;
|
||||
cout << Feld[n-1] << endl;
|
||||
#ifdef DEBUG
|
||||
cout << "\nKKK";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
cout << "Wieviele Schleifen sollen geschachtelt werden (max.100):";
|
||||
cin >> n;
|
||||
cout << "Anfangen bei:";
|
||||
cin >> anfang;
|
||||
cout << "Ende bei:";
|
||||
cin >> ende;
|
||||
cout << endl;
|
||||
ForS(0);
|
||||
}
|
||||
9
pointer_char.c
Normal file
9
pointer_char.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char *Pc="Hallo\n";
|
||||
printf("%s",Pc);
|
||||
Pc="Mull\n";
|
||||
printf("%s",Pc);
|
||||
}
|
||||
BIN
pointer_char2
Normal file
BIN
pointer_char2
Normal file
Binary file not shown.
27
pointer_char2.c
Normal file
27
pointer_char2.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char **Pc=(char**) malloc(110000*(sizeof(char*)));
|
||||
char a;
|
||||
int i;
|
||||
for (i=0;i < 11000 ; i++)
|
||||
{
|
||||
Pc[i]="Kuhl ist dodahl guddie ohne Kombromiesen ;-))\n";
|
||||
}
|
||||
for (i=0;i < 11;i++)
|
||||
printf("%s",Pc[i]);
|
||||
|
||||
printf("Die Größe eines char ist : %d\n",sizeof(char));
|
||||
printf("Die Größe eines char* ist : %d\n",sizeof(char*));
|
||||
printf("Die Größe eines char** ist: %d\n",sizeof(char**));
|
||||
printf("Die Größe eines int* ist : %d\n",sizeof(int*));
|
||||
printf("Die Größe eines int ist : %d\n",sizeof(int));
|
||||
printf("Die Größe eines short* ist: %d\n",sizeof(short*));
|
||||
printf("Die Größe eines short ist : %d\n",sizeof(short));
|
||||
printf("Die Größe eines long* ist : %d\n",sizeof(long*));
|
||||
printf("Die Größe eines long ist : %d\n",sizeof(long));
|
||||
a=getchar();
|
||||
|
||||
free(Pc);
|
||||
}
|
||||
BIN
pointer_char3
Normal file
BIN
pointer_char3
Normal file
Binary file not shown.
16
pointer_char3.c
Normal file
16
pointer_char3.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
//char **Pc=(char**) malloc(11*(sizeof(char*)));
|
||||
char *Pc[110000];
|
||||
char a;
|
||||
int i;
|
||||
for (i=0;i < 11000 ; i++)
|
||||
{
|
||||
Pc[i]="Kuhl ist dodahl guddie ohne Kombromiesen ;-))\n";
|
||||
}
|
||||
for (i=0;i < 11;i++)
|
||||
printf("%s",Pc[i]);
|
||||
a=getchar();
|
||||
}
|
||||
15
pointer_int.c
Normal file
15
pointer_int.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a[10], *Pa;
|
||||
int i;
|
||||
|
||||
for (Pa=a, i=0;i < 10; *Pa++=i++)
|
||||
;
|
||||
|
||||
for (Pa=a, i=0;i < 10; i++)
|
||||
printf("Wert an der Stelle (%d): %d\n",i,*Pa++);
|
||||
|
||||
|
||||
}
|
||||
30
polymorph.cc
Normal file
30
polymorph.cc
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <iostream.h>
|
||||
class Base
|
||||
{
|
||||
public:
|
||||
virtual void fn()
|
||||
{ cout << "In Base Klasse \n"; }
|
||||
};
|
||||
class SubClass : public Base
|
||||
{
|
||||
public:
|
||||
virtual void fn()
|
||||
{cout << "In Sub Klasse\n";}
|
||||
};
|
||||
|
||||
void test(Base &b)
|
||||
{
|
||||
b.fn();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Base bc;
|
||||
SubClass sc;
|
||||
cout << "bc aufrufen\n";
|
||||
test(bc);
|
||||
cout << "sc aufrufen\n";
|
||||
test(sc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
BIN
polymorph.e
Normal file
BIN
polymorph.e
Normal file
Binary file not shown.
10
pp.c
Normal file
10
pp.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
void main()
|
||||
{
|
||||
outb(0,"378");
|
||||
}
|
||||
7
pppo.c
Normal file
7
pppo.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
outb(0,$378);
|
||||
}
|
||||
9
rnd.c
Normal file
9
rnd.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int Ergebnis;
|
||||
int main()
|
||||
{
|
||||
Ergebnis = rand ();
|
||||
printf("Variable = %05d\n", Ergebnis);
|
||||
return(0);
|
||||
}
|
||||
72
roemer.cc
Normal file
72
roemer.cc
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <iostream.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int zahl;
|
||||
int lv;
|
||||
int i,x,c,m,v,l,d;
|
||||
|
||||
cout << "Zahl:";
|
||||
cin >> zahl;
|
||||
|
||||
m = zahl / 1000;
|
||||
zahl -= m*1000;
|
||||
|
||||
d = zahl / 500;
|
||||
zahl -= d*500;
|
||||
|
||||
c = zahl / 100;
|
||||
zahl -= c*100;
|
||||
|
||||
l = zahl / 50;
|
||||
zahl -= l*50;
|
||||
|
||||
x = zahl / 10;
|
||||
zahl -= x*10;
|
||||
|
||||
v = zahl / 5;
|
||||
zahl -= v*5;
|
||||
|
||||
i = zahl;
|
||||
zahl -= i;
|
||||
|
||||
cout << "M;D;C;L;X;V;I"<< endl << m << ";" << d << ";" << c << ";" << l << ";" << x << ";" << v << ";" << i << endl << endl ;
|
||||
|
||||
for (lv = 0; lv < m; lv++)
|
||||
{
|
||||
cout << "M";
|
||||
}
|
||||
|
||||
for (lv = 0; lv < d; lv++)
|
||||
{
|
||||
cout << "D";
|
||||
}
|
||||
|
||||
for (lv = 0; lv < c; lv++)
|
||||
{
|
||||
cout << "C";
|
||||
}
|
||||
|
||||
for (lv = 0; lv < l; lv++)
|
||||
{
|
||||
cout << "L";
|
||||
}
|
||||
|
||||
for (lv = 0; lv < x; lv++)
|
||||
{
|
||||
cout << "X";
|
||||
}
|
||||
|
||||
for (lv = 0; lv < v; lv++)
|
||||
{
|
||||
cout << "V";
|
||||
}
|
||||
|
||||
for (lv = 0; lv < i; lv++)
|
||||
{
|
||||
cout << "I";
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
16
shiftop.c
Normal file
16
shiftop.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
int main ()
|
||||
{
|
||||
signed int x1;
|
||||
unsigned int x2;
|
||||
x1 = -1;
|
||||
x2 = x1;
|
||||
fputs("\x1b[2J", stdout);
|
||||
printf ("\n Norm: %04d d", x1);
|
||||
printf ("\n Rechts (VZ): %04d d", x1 >> 2);
|
||||
printf ("\n Links (VZ): %04d d", x1 << 2);
|
||||
printf ("\n Norm: %04u u", x2);
|
||||
printf ("\n Rechts %04u u", x2 >> 2);
|
||||
printf ("\n Links %04u u", x2 << 2);
|
||||
return(0);
|
||||
}
|
||||
46
strings.cc
Normal file
46
strings.cc
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int erg;
|
||||
size_t pos;
|
||||
string text1;
|
||||
string text2;
|
||||
string nachrichten;
|
||||
|
||||
cout << "Geben Sie zwei Strings ein\n";
|
||||
cin >> text1 >> text2;
|
||||
|
||||
erg = text1.compare(text2);
|
||||
cout << endl;
|
||||
if (erg == 0)
|
||||
nachricht = "Die Zeichenketten sind gleich!";
|
||||
else
|
||||
if (erg > 0)
|
||||
nachricht = "Die erste Zeichenkette ist größer!";
|
||||
else
|
||||
nachricht = "Die zweite Zeichenkette ist größer";
|
||||
cout << "\t" << nachricht << "\n\n";
|
||||
|
||||
cout << "Text 2 wird in dern String \"Nachricht\" kopiert" << endl;
|
||||
nachricht = text2;
|
||||
cout << "\t Nachricht = " << nachricht << endl << endl;
|
||||
|
||||
cout << "Text1 wird auf Vorkommen des Buchstabens i überprüft" << endl;
|
||||
|
||||
pos = nachricht.find("i");
|
||||
pos++;
|
||||
|
||||
if (pos)
|
||||
{
|
||||
cout << "i Wurde in Strng " << nachricht << " an Position " << pos << " gefunden " << endl << endl;
|
||||
}
|
||||
else
|
||||
cout << " i kommt in " << nachricht << " nicht vor \n\n";
|
||||
|
||||
cout << "Text2 wird an Text1 angehängt" << endl;
|
||||
text1.append(text2);
|
||||
cout << "\tErgebnin = " << text1 << "\n\n";
|
||||
return 0;
|
||||
}
|
||||
21
stringtest1.cc
Normal file
21
stringtest1.cc
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdlib.h>
|
||||
#include <iostream.h>
|
||||
|
||||
void main()
|
||||
{
|
||||
char** text=(char**) malloc(10*sizeof(char(*)));
|
||||
int i;
|
||||
|
||||
text[0]="Null";
|
||||
text[1]="Eins";
|
||||
text[2]="Zwei";
|
||||
text[3]="Drei";
|
||||
|
||||
for (i=0;i<6;i++)
|
||||
{
|
||||
cout << text[i] << endl;
|
||||
}
|
||||
|
||||
free(text);
|
||||
|
||||
}
|
||||
23
struct1.c
Normal file
23
struct1.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
|
||||
struct a
|
||||
{
|
||||
int a1;
|
||||
} ;
|
||||
|
||||
struct b
|
||||
{
|
||||
int b1;
|
||||
struct a b2;
|
||||
} ;
|
||||
|
||||
int main()
|
||||
{
|
||||
struct b sb;
|
||||
|
||||
sb.b1=1;
|
||||
sb.b2.a1=2;
|
||||
|
||||
printf("%d : %d",sb.b1,sb.b2.a1);
|
||||
return 0;
|
||||
}
|
||||
30
struct2.c
Normal file
30
struct2.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
|
||||
struct a
|
||||
{
|
||||
int a1;
|
||||
} ;
|
||||
|
||||
struct b
|
||||
{
|
||||
int b1;
|
||||
struct a b2[1000];
|
||||
} ;
|
||||
|
||||
int main()
|
||||
{
|
||||
struct b sb;
|
||||
|
||||
sb.b1=1;
|
||||
sb.b2[0].a1=2;
|
||||
sb.b2[1].a1=3;
|
||||
sb.b2[2].a1=4;
|
||||
sb.b2[3].a1=5;
|
||||
|
||||
printf("+%d :\n",sb.b1);
|
||||
printf(" -%d:\n",sb.b2[0].a1);
|
||||
printf(" -%d:\n",sb.b2[1].a1);
|
||||
printf(" -%d:\n",sb.b2[2].a1);
|
||||
printf(" -%d:\n",sb.b2[3].a1);
|
||||
return 0;
|
||||
}
|
||||
20
swiblok.c
Normal file
20
swiblok.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* Falluntersuchung und Konstante */
|
||||
/* swiblok.c */
|
||||
#include <stdio.h>
|
||||
int main ()
|
||||
{
|
||||
char c;
|
||||
puts("\x1b[2J");
|
||||
printf ("Tippen Sie Buchstaben oder Tab\n");
|
||||
switch (c = getchar())
|
||||
{
|
||||
int hilfe;
|
||||
case '\t' : printf("\nTabulator.\n"); break;
|
||||
case 'A' : printf("\nGroßes A\n"); hilfe = 1; break;
|
||||
case '\x81':printf("\nUmlaut\n"); break;
|
||||
default : hilfe = c;
|
||||
printf("\n Wert %04x\n",hilfe); break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
6
test.c
Normal file
6
test.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
void main()
|
||||
{
|
||||
puts("\n test \n");
|
||||
return(0);
|
||||
}
|
||||
BIN
test.datei
Normal file
BIN
test.datei
Normal file
Binary file not shown.
BIN
test_string
Normal file
BIN
test_string
Normal file
Binary file not shown.
10
test_string.c
Normal file
10
test_string.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
char text[70] = "Hallo";
|
||||
printf("\n text:");
|
||||
gets(text);
|
||||
puts(text);
|
||||
}
|
||||
BIN
testmalloc
Normal file
BIN
testmalloc
Normal file
Binary file not shown.
38
testmalloc.cc
Normal file
38
testmalloc.cc
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <iostream.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// Variablen deklarieren
|
||||
int a,i;
|
||||
int *pa,*pb;
|
||||
|
||||
// Speicher für 5 Elemente reservieren
|
||||
pa= malloc(5*sizeof(a));
|
||||
|
||||
// Pointer Sichern
|
||||
pb=pa;
|
||||
|
||||
// Elemente füllen
|
||||
for(i=0;i<5;i++)
|
||||
{
|
||||
*pb=i;
|
||||
// Nächstes Element
|
||||
pb++;
|
||||
}
|
||||
|
||||
// Pointer wieder auf Erstes Element zurücksetzen
|
||||
pb=pa;
|
||||
|
||||
// Elemente ausgeben
|
||||
for(i=0;i<5;i++)
|
||||
{
|
||||
cout << pb << "::" << *pb << "::" << endl;
|
||||
pb++;
|
||||
}
|
||||
|
||||
// Alloszierter Speicher freigeben
|
||||
free(pa);
|
||||
|
||||
return 0;
|
||||
}
|
||||
8
testx.c
Normal file
8
testx.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include<stdio.h>
|
||||
int main ()
|
||||
{
|
||||
char text[16];
|
||||
scanf("%c",&text);
|
||||
printf("test %c",text);
|
||||
return(0);
|
||||
}
|
||||
28
varnum.c
Normal file
28
varnum.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
-- Das sollte man besser mathematisch lösen, siehe 10tox
|
||||
char c[20];
|
||||
|
||||
int basis=10;
|
||||
int len=2;
|
||||
int max;
|
||||
int stelle;
|
||||
|
||||
int i;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
for (i=0;i < len;c[i++]='0')
|
||||
;
|
||||
|
||||
max=len;
|
||||
while (max >= 0)
|
||||
{
|
||||
stelle=max--;
|
||||
for (i=0;i < basis;i++)
|
||||
{
|
||||
c[stelle]=i+'0';
|
||||
printf("%s\n",c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user