- #1
- 6,735
- 2,458
[SOLVED] C- programming: Reading filename from keyboard
Hi!
I am trying to write a small program for open a file by entering filename with keyboard, but it does not work. Why?
int main(){
FILE *fp;
printf("Give filename ");
char str[100], *s;
s = fgets(str, 100 , stdin);
printf("\n");
fp = fopen(str, "r");
-----------
No file opens.. :(
Hi!
I am trying to write a small program for open a file by entering filename with keyboard, but it does not work. Why?
int main(){
FILE *fp;
printf("Give filename ");
char str[100], *s;
s = fgets(str, 100 , stdin);
printf("\n");
fp = fopen(str, "r");
-----------
No file opens.. :(