Browse Source

Added files

master
Rainer Hihn 3 years ago
parent
commit
7ad78dceae
1 changed files with 84 additions and 0 deletions
  1. +84
    -0
      laenge.c

+ 84
- 0
laenge.c View File

@@ -0,0 +1,84 @@
/***********************
* Stringstats
*
* Rainer Hihn
*/

#include <stdio.h>
#define LENGTH 64

/*
* Funktion deklarieren
*/
int stringstats(char[], char *, char *);

int stringstats(char sString[], char* cGroesster, char* cKleinster)
{
/**
* Variablendeklaration
*/
int iLength = 0;
int i = 0;
*cKleinster = sString[0];
*cGroesster = sString[0];

while(sString[iLength] != '\0')
{
iLength++;

}

for(i = 0; i <= iLength-1; i++)
{
if(sString[i] < *cKleinster)
{
*cKleinster = sString[i];
}

if(sString[i] > *cGroesster)
{
*cGroesster = sString[i];
}
}

return iLength;
}

int main(void)
{
/**
* Variablendeklaration
*/
char cString[LENGTH] = {0};
int iLength = 0;
char cGroesster = 0;
char cKleinster = 0;

while(1)
{
/**
* Benutzereingabe String
*/
printf("Bitte einen String eingeben ('q' fuer Beenden) \n");
scanf("%62s", &cString);

/**
* Abbruchbedingung pruefen
*/
if(cString[0] == 'q' && cString[1] == '\0')
{
break;
}

/**
* Funktion stringstats aufrufen
*/
iLength = stringstats(cString, &cGroesster, &cKleinster);

printf("Laenge: %i \n", iLength);
printf("Kleinster Buchstabe: %c \n", cKleinster);
printf("Groesster Buchstabe: %c \n\n", cGroesster);
}

return 0;
}

Loading…
Cancel
Save