fork(1) download
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <stdint.h> // Datentypen
  4.  
  5. #pragma warning(disable : 4996)
  6.  
  7. void einfacheDatentypen()
  8. {
  9. int izahl = 0;
  10. short int szahl = 0; // %hd
  11. float fzahl = 0.0;
  12. double dzahl = 0.0;
  13.  
  14. printf("\n\t\teinfacheDatentypen\n");
  15. printf("Zahlen int: %d, float: %f, double: %e", izahl, fzahl, dzahl);
  16.  
  17. // http://w...content-available-to-author-only...t.de/doc/cpp/printf/printf.html#Print-Conversion-Specifiers
  18. }
  19.  
  20. void initFelder()
  21. {
  22. int izahl[10];
  23. float fzahl[5] = {0.0, 0.0, 0.0, 0.0, 0.0};
  24. char zeichen[10];
  25. uint8_t ui8zahl[10];
  26.  
  27. printf("\n\t\tinitFelder\n");
  28.  
  29. for (int i = 0; i < 10; i++)
  30. {
  31. izahl[i] = 0;
  32. }
  33.  
  34. for (int i = 0; i < 10; i++)
  35. {
  36. ui8zahl[i] = 0;
  37. }
  38.  
  39. printf("\nui8\n");
  40. for (int i = 0; i < 10; i++)
  41. {
  42. printf("%d ", ui8zahl[i]);
  43. }
  44.  
  45. for (int i = 0; i < 5; i++)
  46. {
  47. printf("%f ", fzahl[i]);
  48. }
  49. printf("\n");
  50.  
  51. int j = 0;
  52. do{
  53. zeichen[j++] = ' ';
  54. } while (j < 10);
  55.  
  56. printf("\n");
  57. j=0;
  58. while (j++ < 10)
  59. {
  60. printf("%f ", fzahl);
  61. }
  62. }
  63.  
  64. void charUndString()
  65. {
  66. char zeichen = '1';
  67. char str1[] = "Das ist ein String";
  68. char str2[] = {'A', 'B', 'C', 0 };
  69.  
  70.  
  71. printf("\n\t\tcharUndString\n");
  72.  
  73. printf("Zahl: %d", zeichen -'0');
  74. printf("\nString 1: %s, String 2: %s", str1, str2);
  75. }
  76.  
  77. void nurBestimmteWerteAblegen()
  78. {
  79. char str1[20] = "Test1234String";
  80. char str2[20];
  81. char zeichen;
  82. int j = 0, i = 0;
  83.  
  84. while((zeichen=str1[i++]) != 0)
  85. {
  86. if(zeichen >= '0' && zeichen <= '9') // https://d...content-available-to-author-only...a.org/wiki/American_Standard_Code_for_Information_Interchange#ASCII-Tabelle
  87. str2[j++] = zeichen;
  88. }
  89. str2[j]=0;
  90. printf("\nString2: %s\n", str2);
  91. }
  92.  
  93. int main(void)
  94. {
  95. einfacheDatentypen();
  96. initFelder();
  97. charUndString();
  98. nurBestimmteWerteAblegen();
  99.  
  100. fflush(stdin);
  101. getchar();
  102. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
		einfacheDatentypen
Zahlen int: 0, float: 0.000000, double: 0.000000e+00
		initFelder

ui8
0 0 0 0 0 0 0 0 0 0 0.000000 0.000000 0.000000 0.000000 0.000000 

0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 
		charUndString
Zahl: 1
String 1: Das ist ein String, String 2: ABC
String2: 1234