Please support our C advertiser: Programming Forums
Views: 736 | Replies: 4
![]() |
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,639
Reputation:
Rep Power: 40
Solved Threads: 986
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.
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
Location: Israel
Posts: 37
Reputation:
Rep Power: 3
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?
I guess i didnt see it - sorry mate
•
•
Join Date: Jan 2006
Location: Israel
Posts: 37
Reputation:
Rep Power: 3
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.
strcpy(univ->std[num_cells].name,buffer);
I did just that . now it messes up another string - i'll figure it out
somehow , the thing is , we were never tought the subject BUFSIZ and
"sscanf" - so no offence there
i got slapped on using it .... sorry
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode