Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7193

Is it possible to crash this program somehow?

$
0
0

I am currently learning C in one of my courses at the university. Now we have a task to solve and I am not sure how to do it.

The task looks like this:"Is it possible to let this program crash with user inputs? If so, explain this case."

The program we have been given is quite simple and looks like this:

#include <stdio.h>  // Include to use printf, scanfint main(){    // Define buffers to store user name and password    char username[16];    char password[16];    // Read username and password from user input    printf("Enter your name: ");    scanf("%s", username);    printf("Enter your password: ");    scanf("%s", password);    printf("[SHOUTING OUT LOUD] Hello, %s!\n", username);    return 0;}   

I already found out, that you can make the program print out the password, if you use a username longer than 15 chars. But this is obviously not a crash.So I haven't found a way to crash the program, but somehow I am pretty sure, that there is a way to do this.Does somebody has any idea?

Thanks :)


Viewing all articles
Browse latest Browse all 7193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>