Fehler suche!
-
#include <stdio.h>
#include <string.h>int main(int argc, char**argv) {
/* 1kb Speicher */
char text[1024);
/* erstes Zeichen auf0 -> Leersting */
Text[0] = '\0';
printf("Laenge von >%s<: %i\n,
text, strlen(text));
Text[0] = ,T';
text[1] = ,e';
text[2] = ,s';
text[3] = ,t';
text[4] =,\0';
printf("Laenge von >%s<: %i\n,
text, strlen(text));
return 0;
}Hallo !
Wollte fragen wo der fehler ist wenn es einen fehler gibt oder das ding nicht vollständig ist !
Oder habe ich es nur fasch Compriemiert ?
Was passiert wenn es richtig als programm geschrieben ist ?
Ich habe es aus einem buch und bin ein absuluter noob in solchen sachendan baba
PS: wie compriemiert man das in linux ?
gcc test -o test
?mfg Benny
-
In die Konsole: g++ -o foo foo.cpp
hier deine Fehlerausgabe:
nimms.cpp: In functionint main(int, char**)': nimms.cpp:7: error: parse error before
)' token
nimms.cpp:9: error:Text' undeclared (first use this function) nimms.cpp:9: error: (Each undeclared identifier is reported only once for each function it appears in.) nimms.cpp:10:16: missing terminating " character nimms.cpp:11: error: parse error before
,' token
nimms.cpp:12: error: parse error before `,' token
nimms.cpp:12:21: missing terminating ' character
nimms.cpp:13:21: missing terminating ' character
nimms.cpp:14:21: missing terminating ' character
nimms.cpp:15:21: missing terminating ' character
nimms.cpp:16: error: stray '\' in program
nimms.cpp:16:21: missing terminating ' character
nimms.cpp:17:16: missing terminating " characterich habs unter dem namen nimms kompiliert
Edit2: Wenns aus nem Buch ist, hast du es falsch abgeschrieben, da es etliche Syntaxfehler gibt.
-
#include <iostream> int main() { char text[5]; text[0] = '\0'; std::cout << "Laenge von text: " << strlen(text) << std::endl; text[0] = 'T'; text[1] = 'e'; text[2] = 's'; text[3] = 't'; text[4] = '\0'; std::cout << "Laenge von text: " << strlen(text) << std::endl; }
Wobei man für solche Dinge std::string benutzt
Hast du schon einmal versucht deinen Code zu compilieren?
Für C++ verwendet man g++ und nicht gcc.
Naja, die Ausgabe ist lediglich:
Laenge von text: 0
Laenge von text: 4
-
Danke ^.-
also da ich seher sehr neu bin müsst ihr es ferstehen ^^
mfg Benny !