Markus Rechberger / CErrors
 
StartSeite | MarkusRechberger/ | Neues | TestSeite | ForumSeite | Teilnehmer | Kategorien | Index | Hilfe | Einstellungen | Ändern

Veränderung (zum vorhergehenden Autor) (Änderung, Korrektur, Normalansicht)

Verändert: 1c1,57
Beschreibe hier die neue Seite.
irc#c

[[Code]
Problem:
01:06 < alt_don> having problems getting the syntax down
01:07 < alt_don> it compiles fine with gcc -Wall
01:07 < alt_don> but does not work as I intend it to
01:10 < alt_don> I am new to C so I don't see my mistake
]

[[Code]
#include <stdio.h>

char user_input[128];
int term1;
int term2;
int term4;

int main(int argc, char *argv[])

{
printf("please enter two values here: ");

fgets(user_input, sizeof(user_input), stdin);
sscanf(user_input, "%d %d", &term1, &term2);

if (argc < 2)

printf("you need to input at least two characters here\n");

else

term4 = term1 + term2;
printf("%d", term4);

return (0);
}
]

don't correct it .. just think about it :-) this is a nice one




[[Code]
#include <stdio.h>
#include <string.h>

int main(){
char *string=0;
printf("%d",strlen(string));
return(0);
}
]

strlen is not NULL pointer safe




irc#c

Problem:
01:06 < alt_don> having problems getting the syntax down
01:07 < alt_don> it compiles fine with gcc -Wall
01:07 < alt_don> but does not work as I intend it to
01:10 < alt_don> I am new to C so I don't see my mistake

#include <stdio.h>                                                                                                                                                                  
 
char user_input[128];                                                                                                                                                               
int term1;                                                                                                                                                                          
int term2;                                                                                                                                                                          
int term4;                                                                                                                                                                          
 
int main(int argc, char *argv[])                                                                                                                                                    
 
{                                                                                                                                                                                   
    printf("please enter two values here: ");                                                                                                                                       
 
    fgets(user_input, sizeof(user_input), stdin);                                                                                                                                   
    sscanf(user_input, "%d %d", &term1, &term2);                                                                                                                                    
 
    if (argc < 2)                                                                                                                                                                   
 
    printf("you need to input at least two characters here\n");                                                                                                                     
 
    else                                                                                                                                                                            
 
    term4 = term1 + term2;                                                                                                                                                          
    printf("%d", term4);                                                                                                                                                            
 
return (0);                                                                                                                                                                         
}

don't correct it .. just think about it :-) this is a nice one


#include <stdio.h>
#include <string.h>

int main(){
        char *string=0;
        printf("%d",strlen(string));
        return(0);
}

strlen is not NULL pointer safe



StartSeite | MarkusRechberger/ | Neues | TestSeite | ForumSeite | Teilnehmer | Kategorien | Index | Hilfe | Einstellungen | Ändern
Text dieser Seite ändern (zuletzt geändert: 2. Dezember 2004 1:09 (diff))
Suchbegriff: gesucht wird
im Titel
im Text