| | |
Basic file handing
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2008
Posts: 15
Reputation:
Solved Threads: 1
I am still working on the lovely trie project, now I am working on file input that will be passed into the trie. I receive the following errors when I compile this code.
I would like to be able to remove these warnings but the more pressing issue is this bus error:
And of course here is the source code for this:
Any idea what is causing this bus error? Also the c file does exist and I do have read permissions. As does .WORDS .
C Syntax (Toggle Plain Text)
$ make gcc -Wall -g -c -o spellback.o spellback.c spellback.c: In function ‘main’: spellback.c:36: warning: implicit declaration of function ‘open’ spellback.c:36: warning: assignment makes pointer from integer without a cast spellback.c:16: warning: unused variable ‘line’ gcc -Wall -g -o simplespell node.o spellback.o
I would like to be able to remove these warnings but the more pressing issue is this bus error:
C Syntax (Toggle Plain Text)
$ ./simplespell -w filer.c Opening default file Closed default file Opening selected file Bus error
And of course here is the source code for this:
c Syntax (Toggle Plain Text)
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <stdbool.h> #include "node.h" #define MAXSIZE 2048 int main(int argc, char *argv[]){ int ck; ck = argc; //printf("%d\n", ck); FILE *fp; char line [MAXSIZE]; if(ck == 1){ printf("Opening default file\n"); fp = fopen(".WORDS", "r"); fclose(fp); printf("Closed default file\n"); } if(ck == 2){ printf("Invalid Input\n"); } if(ck == 3){ printf("Opening default file\n"); fp = fopen(".WORDS", "r"); fclose(fp); //point fp to next file printf("Closed default file\n"); fp = open(argv[2], "r"); printf("Opening selected file\n"); fclose(fp); printf("Closed selected file\n"); } return 0; }
Any idea what is causing this bus error? Also the c file does exist and I do have read permissions. As does .WORDS .
![]() |
Similar Threads
- plzzzz..i need help..im due wit this project.kinda lost in codes.anyone culd help me (Visual Basic 4 / 5 / 6)
- Need help on VBP Assignment (Visual Basic 4 / 5 / 6)
Other Threads in the C Forum
- Previous Thread: Segmentation fault C
- Next Thread: program to read directories in UNIX help
Views: 502 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C
* adobe api append array arrays bash binarysearch char character cm copyanyfile copypdffile createcopyoffile createprocess() csyntax directory drawing dynamic executable execv feet fgets file floatingpointvalidation fork frequency function getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux highest homework i/o ide include infiniteloop initialization interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list matrix meter microsoft mqqueue multi mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scheduling segmentationfault send single socketprogramming spoonfeeding stack standard strchr string student suggestions system test testautomation unix urboc user whythiscodecausesegmentationfault win32 win32api windows.h





, I need to be a bit more careful it seems. 