| | |
Changing the contents of a file
I'm working on a program to score a bowling game. Right now, my terminal says that my program has a seg fault, but I can't tell where. Any other insight on how to help my program do what it's supposed to do would be helpful. I'm still not sure how to weed out all the characters, although I think my fscanf might do that.
/* * This program is designed to open an existing file, lane9.txt, * which has a collection of integers and characters. It then takes * the characters out, leaving only the integers and spaces. */ #include <stdio.h> int main () { FILE* fp; fp = fopen("lane9.txt", "r"); int i; int throw[i]; int n = 20; if (fp == NULL) { printf("Error: file lane9.txt could not be opened\n"); return 0; } for (i = 0; i < n; i++) { fscanf(fp,"%2d %*s", &throw[i]); } for(i=0;i<n; i++); { printf("%d ",throw[i]); } return 0; }
Similar Threads
- how to delete the previous contents in the file (Java)
- Deleting contents of a file before writing (Java)
- Text File Too Large To Display Entire Contents (C++)
- Read text file contents per line (C++)
- Need Help to read .txt file and store its contents (Java)
- Replacing file contents (Python)
- Insert Contents Of Text File Into Database (ASP.NET)
- Read from a csv file (C)
- trouble with counting letter from file, please help. (C++)
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks bash binarysearch centimeter changingto char character convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop initialization input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux list lists locate looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation owf pdf pointer pointers posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi



