473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Checking for the end of a line

TimNick90
I am writing a program for a class of mine to pull a students initials as well as a list of their letter grades from a file and calculate their gpa. In the file there is one student and their grades per line. Each student can have an infinate amount of grades, and their could be an infinate amount of students. I am having trouble with starting a new students gpa. The only way I can think of would be to check for the end of a line. The only problem with this is I am using a string to take the initials and grades from the file and using a char to check for '\n' would be off set, due to the string reaching the end of the line before the char. If anyone could help me figure out a way to solve this it would be much appreciated.

Thanks,
TimNick

PS: if you wish to see my code I can PM it to you.
Feb 21 '08 #1
2 1152
Ganon11
3,652 Expert 2GB
...The only problem with this is I am using a string to take the initials and grades from the file and using a char to check for '\n' would be off set, due to the string reaching the end of the line before the char...
Could you elaborate on this point? What exactly are you trying to do, and why exactly do you think it won't work?

If necessary, you can post a portion of your code to the thread - just make sure you use [code] tags.
Feb 21 '08 #2
Could you elaborate on this point? What exactly are you trying to do, and why exactly do you think it won't work?

If necessary, you can post a portion of your code to the thread - just make sure you use ['CODE'] tags.
The program pulls the informations out of a file and then prints the sutdents initials as well as their gpa based on their grades given. The format for the informations in the file is:

Expand|Select|Wrap|Line Numbers
  1. JKL A B C D E
  2. MNO A B B
  3.  
So it should look like this:

Expand|Select|Wrap|Line Numbers
  1. Sutdent Initials       Students GPA
  2.      JKL                             2
  3.    MNO                       2.333
  4.  
What I have it doing is running through a loop checking for the end of the file so it will get all of the information. It also needs to be running through another loop checking for the end of the line. The only way I know of to check for the end of a line is with a char and check to see if it equals '\n'. I am unsure of how to do this because I am using a string to pull the initials and grades. Won't the string get to the end of the line before the char if it's running throught the same loop? This would cause the string to start taking information from the next line while the char is still on the first one.
Feb 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Qopit | last post by:
Hi there, I'm pretty new to Python and am trying to figure out how to get "will this code compile?"-like code checking. To me this is a pretty basic language/environment requirement, especially...
99
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
8
by: Brendan | last post by:
There must be an easy way to do this: For classes that contain very simple data tables, I like to do something like this: class Things(Object): def __init__(self, x, y, z): #assert that x,...
2
by: Dariusz Tomon | last post by:
Hi I embedded in HTML code checking my form before sending it: I get the following error: What is the way to do JS checking on the form with runat="server"? Regards Darek T
1
by: halcyon943 | last post by:
have 4 folders that I watch and need to move files from to another location. Three constraints: -Finish time. Make sure the program stops transferring files at a specific time -Number of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.