| | |
C problen with Files
![]() |
In function input_university() I see where scanf() is reading the string, and univ->std[num_cells].name is getting allocated, but I don't see where it is copying buffer to univ->std[num_cells].name after allocation. Add this and it will probably work ok.
C Syntax (Toggle Plain Text)
strcpy(univ->std[num_cells].name,buffer);
Apparently, I wasted my time :mad:
http://www.daniweb.com/techtalkforums/thread43435.html
Not only have you dropped the initialisation of univ in main(), but you've gone back to using fscanf to read the file.
Not only that, you're now using global variables like "temp", which get allocated on every iteration of the loop and never freed.
Don't forget the not using a temporary variable when calling realloc, nor the unnecessary casting of malloc and realloc.
Y'know what, if you're just going to ignore people, just say so - ok?
http://www.daniweb.com/techtalkforums/thread43435.html
Not only have you dropped the initialisation of univ in main(), but you've gone back to using fscanf to read the file.
Not only that, you're now using global variables like "temp", which get allocated on every iteration of the loop and never freed.
Don't forget the not using a temporary variable when calling realloc, nor the unnecessary casting of malloc and realloc.
Y'know what, if you're just going to ignore people, just say so - ok?
•
•
Join Date: Jan 2006
Posts: 38
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Salem
Apparently, I wasted my time :mad:
http://www.daniweb.com/techtalkforums/thread43435.html
Not only have you dropped the initialisation of univ in main(), but you've gone back to using fscanf to read the file.
Not only that, you're now using global variables like "temp", which get allocated on every iteration of the loop and never freed.
Don't forget the not using a temporary variable when calling realloc, nor the unnecessary casting of malloc and realloc.
Y'know what, if you're just going to ignore people, just say so - ok?
•
•
Join Date: Jan 2006
Posts: 38
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Ancient Dragon
In function input_university() I see where scanf() is reading the string, and univ->std[num_cells].name is getting allocated, but I don't see where it is copying buffer to univ->std[num_cells].name after allocation. Add this and it will probably work ok.
C Syntax (Toggle Plain Text)
strcpy(univ->std[num_cells].name,buffer);
somehow , the thing is , we were never tought the subject BUFSIZ and
"sscanf" - so no offence there
i got slapped on using it .... sorry
![]() |
Similar Threads
- "Save Target As.." isn't working in IE6 (Web Browsers)
- hjsplit doenst work for avi files? (Windows NT / 2000 / XP)
- Does Samba send deleted files to a recycle bin? (*nix Software)
- Dia, .PDB files (C++)
- Cannot transfer files from one hardrive to another =[ please help (Windows NT / 2000 / XP)
- FTP files (Geeks' Lounge)
Other Threads in the C Forum
- Previous Thread: Help me. binary seach tree
- Next Thread: deleting operation
Views: 968 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C
api array arrays binary binarysearch c++ char character code codes coke command conversion convert copyanyfile copypdffile database decimal directory dude dynamic ebooks error exec factorial fgets file files fork function functions getlogicaldrivestrin givemetehcodez global grade graphics hacking homework i/o ide input insert int integer lazy libcurl license line linked linkedlist linux list lists loop loops malloc matrix memory messagebox mysql no-effort number output path pause performance pointer pointers problem process program programming questions read recursion recursive recv reverse roman2decimal scanf socketprograming spoonfeeding sql static strchr string strings strtok structures student studio system turbo turbo-c unix user variable wab why-not-to-use-turbo windows






