Geschrieben von x_mushroom am 24.10.2009 um 12:16:
Brauche Hilfe beim C-Programmieren
Hey ihr
Ich hoffe ich bin hier in der richtigen Rubrik. Also, ich bin an ner HTL & habe dort auch Programmierunterricht. Allerdings bin ich erst im ersten Jahr und habe auch erst seit ca 3 - Wochen unterricht xD
Also, letzte Unterrichtsstunde war ich leider krank & habe einige wichtige Sachen verpasst. & über das Wochenende muss ich ne Aufgabe abgeben =/
Ich hoffe es gibt hier den ein oder anderen der C beherrscht & mir etwas helfen kann
Also die Aufgabenstellung ist folgende

Das ganze soll ein einfaches Konsolendingens sein xD]
Zitat: |
Schreiben Sie ein Programm, das mit Hilfe der Variablen
char wort[]="Programmieren";
float a=(float)10.0/3.0;
double b=-100.0/3.0;
folgende Ausgabe erzeugt. In den Formatstrings der printf()-Anweisungen dürfen keine Leerzeichen vorkommen.

|
Also, beim Code bin ich soweit:
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
|
#include <stdio.h>
int main (void)
{
char wort[]="Programmieren";
float a=(float)10.0/3.0;
double b=-100.0/3.0;
printf("%d\n", 123456789012345678901234567890);
printf("%c30\n", wort);
printf(""%c"\n", wort);
printf("\\%c\n", wort);
printf("%c30"; %wort%);
return 0;
}
|
|
& wie es weiter geht bin ich etwas ratlos...& ausserdem: Ich habe das soweit als exe Datei abgespeichert, aber das was ich bereits habe wird nicht ausgeführt =(
whaaa ich bin fast am verzweifeln & muss am Montag fertig sein -.-
/edit
also, ich hab weitergearbeitet, ein paar fehler ausgebessert & bin nun soweit:
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
|
#include <stdio.h>
int main (void)
{ #define char wort[]="Programmieren";
# define float a=(float)10.0/3.0;
# define double b=-100.0/3.0;
printf("%d\n", 123456789012345678901234567890);
printf("%30c\n", wort);
printf(""%c"\n", wort);
printf("\\%c\n", wort);
printf("%30c", %wort%);
printf("%011f\n", 3.333);
printf("%s\n", +003.3e+000);
printf("%s\n" -003.3E+001);
printf("%021.6d\n", a);
printf("%021.10d\n", b);
return 0;
}
|
|
nunja, aber das programm lässt sich nicht starten =/ ich arbeite mit visual c++ 2008 & wenn ich das im programm ausführen will komm eine fehlermeldeung, & auch wenn ich eine exe datei ausführen möchte funktioniert das nicht
man, ich bin echt verzweifelt.
lg.x3
Geschrieben von Ayana am 26.10.2009 um 14:48:
RE: Brauche Hilfe beim C-Programmieren
Zuerstmal: Welche Fehlermeldung kommt denn?
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
|
test.c:9:18: warning: integer constant is too large for its type
test.c: In function ‘main’:
test.c:9: warning: integer constant is too large for ‘long’ type
test.c:9: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘<unnamed-signed:128>’
test.c:11: error: ‘wort’ undeclared (first use in this function)
test.c:11: error: (Each undeclared identifier is reported only once
test.c:11: error: for each function it appears in.)
test.c:14: error: expected expression before ‘%’ token
test.c:17: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘double’
test.c:18: error: invalid operands to binary - (have ‘char *’ and ‘double’)
test.c:20: error: ‘a’ undeclared (first use in this function)
test.c:20: warning: '0' flag ignored with precision and ‘%d’ printf format
test.c:22: error: ‘b’ undeclared (first use in this function)
test.c:22: warning: '0' flag ignored with precision and ‘%d’ printf format |
|
Das gibt gcc unter Linux (Debian) raus.
Vielleicht hilft dir das erstmal weiter, wenn du Fragen zu einzelnen Fehlermeldungen hast, meld dich, bin bereit sie dir zu erklaeren.