Jump to content

File writing Problem

- - - - -

  • Please log in to reply
3 replies to this topic

#1
hbk

hbk

    Learning Programmer

  • Members
  • PipPipPip
  • 71 posts
I am writing contents to file but for the first record its writing like memory addresses or something, any idea what the problem.


  -842150451 -842150451

Cmp-1212 Computer-Logics 1 1

Cmp-1212 Computer-Logics 3 3

Cmp-1212 Computer-Logics 4 5

Cmp-1212 Computer-Logics 5 6



#2
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts
Without any source code, I have no idea what the problem is.
Wow I changed my sig!

#3
hbk

hbk

    Learning Programmer

  • Members
  • PipPipPip
  • 71 posts

courselink  *position;

		 position = new courselink();

		 position->nextcourselink = head;

		 head = position;	


		 fstream file2;

		 file2.open("sortbycredit.txt", ios::out);


		 while (position->nextcourselink !=NULL )

		 {


			 file2 << position->getcoursecode() << " " << position->getcoursename() << " " << position->getcourselevel() << " " << position->getcoursecredit() << endl;

			 

			 position = position->nextcourselink;

		 }

		  head = head->nextcourselink;

		  file2.close();



#4
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
I'm guessing by the spacings in the output that the offending numbers were outputted by the position->getcourselevel() and position->getcoursecredit() methods. I would check to make sure your first list item was initialized correctly.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users