C :: Add More Student Information To The Specific Txt File?
Mar 12, 2013
I'm trying to add more student information to the specific txt file. I did struct my student information and separated it with an array with max size of 200.
The inside of my current file looks like
Toshi
Aka
Nonal
Donald
The first one represent student[0] and next one is student[1] and so on till student[199]. Right now, only 4 space is occupied, which means the array has information till student[3] but not from student[4] (I guess it has null condition).
What I want to do is, I want to add a new student information to student[4] and till student[199] once at each time.
So, my prompt will look like
Would like to add a new student? Y/N
(if yes goes to below statement and exit if NO)
Hi. Please enter the information of new student. ___________
Student added. Please press any key to continue.
If the key is pressed, it goes back to my initial prompt and continues till I press N.
I sure I'm not using for loop to do this thing, because I'm adding student name one by one.
However, the array is already occupied by other student name till student[3] so, I want to add a new student information to student[4] (I don't want to overwrite the current information). And if student[4] is occupied, then [5] and so on.
How to measure a NAS (NTFS) free space/total space and used space? Few more details: I have the needed code to map the NAS location (serverNameshared_folderfoldersub_folder) into the local server where I am running my applciation but I can only get the needed statistics above for the whole NAS, I need to know the statistics for a specified folder on the NAS, how can I do that?
I dont know how to modify the previous record that i have done in the Add Student function. i searched from different sites and got this code for modifying a record in a text file. But, i cant figure it out why its not working.
I have been creating this program for a student registration system. For the file handling So far I can write in to a file , view all records, and search a single record. now i got the problem with updating details . my coding is as bellow ..
The problem is that ... Even though it is reading from a a file, it is not reading a one struct. In this piece of code I'm trying to read the last struct, which should be k... The struct itself is here
The problem is that i dont know how to do because 'getline' won't work i think.
the file looks like this:
******************* Inventory of MyInventory ******************* Some info More info ------------------- 000 Toys 6.25 a short description 126/44 Cards 2.25 some text ******************* Inventory of MyInventory2 ******************* Some info More info ------------------- 000 Toys 6.25 a short description 126/44 Cards 2.25 some text
So what I need to know:
- the name of the Inventory (MyInventory, MyInventory2...)
- the numbers in each row (000,126/44...)
- the name what it is (Toys,Cards...)
- the price (6.25,2.25...)
- and the description(problem here is, that there are not the same amount of words for each description)
I tried it with 'getline' but this is not working because the lines are so different each time.
I want to receive an information from a file. For instance, you created a file name "sample.txt" via fstream and stored a bunch of people's name, address, phone number in that "sample.txt".
Now, I want to see what's stored in this file. Suppose, I wanted some particular guys address, phone number by just typing is his/her name.
How to relate the name with address and phone number of particular people? I just started the file creating so I wanted to know about it.
#include<iostream> #include<conio.h> #include<fstream> #include<string> using namespace std; int main() { ofstream outputData;
so I wrote this code in class today and I'm almost done but I need to come up with some sort of equation to add up all the total values. The problem is I am reading data off a txt file so it's all being read as one thing. I don't know how to get each specific value and add them all together. This is my code so far.
I end up multiplying the amount by the price to get the total value as shown in the code above. Now I just don't know how to add the total value of each item to get the total overall value. Also I haven't used invTotal because I want that to be the overall total.
I want to take the informaition from this file and save it into a struct the file conteins name age year (in char) and a grade it is somthing like this
file Nikos Tolis 19 A 8 Iwanna Nikolaou 20 B 9 Kwstas Doukas 20 Β 6 Georgios Pappas 19 A 7 Iwannis Lekatis 20 Β 7 Nikos Ntoumas 19 A 5 Maria Oikonomou 20 B 6 Kwstas Argyrou 19 A 10 Irw Ntouma 20 B 8 Leuteris Doukas 19 A 6
I want to read till i found the '32' the space in ascii here is my code so far
Code: #include<stdio.h> #include<string.h> #include<stdlib.h> struct students { char *name; int age;
Create a simple data file like the example shown below containing the 4 dates below plus 10 or more additional dates. The file should include 1 date per line and each date should have the form MonthNumber-DayOfTheMonth-Last2DigitsOfTheYear with no extra spaces. All dates should be in this century. No error checking for invalid dates is necessary.
My Output displays like
February -19,1991
How do I get my program to ignore the dash between the dates?
#include <fstream> #include <iostream> #include <string> #include <cmath> using namespace std; int main(){ const int M = 13;
I'm trying to open a text file with the name "text.txt", for the purpose of only displaying in the console an specific part of the text file. For example, if I got "This is a test [TEXT] This is the message that should display [/TEXT] this is the end of the file", I want only "This is the message that should display" to be the output, the thing is that I can't imagine anyway of doing that. what I should do?
I'm trying to open a file (contains member information) and store the information in an object, which is then inserted into a linked list. However, the current code just leaves a blank command window hanging with nothing happening.
I created a simple program that writes some text to two different text files. how to create a program that would retrieve the information from those two files, and put them in a single file, first the content of input1 and then the content of input2. how to do this. Here is the program that I created that creates the two files.
#include <iostream> #include <fstream> #include <string> int main() { using namespace std; string input1; ofstream fout("input1.txt");
this last few days I've been coding this one particular file
Hero.cpp
namespace Hero { namespace { // all data here } }
then the code grew a bit to about 700 line
Then now I want to implement hero skill system It needs the access to data inside the unnamed namespace where I put just about everything.. but it's unnamed namespace, it's only valid within one file and I should hide all that data from Hero interface in Hero.h How should I do this ?
The first row has two values - number of nodes (24) and number of links (76). Then it has all the link details (76 rows of data). I want to read this data. I have written out the following function:
First the structure definitions:
typedef struct { int arcno; int tail; int head; } arc_data; typedef struct { int forwardStarPoint; int reverseStarPoint;
[Code] .....
The code is able to read the first line of data (i.e. it displays the numNodes and numArcs as 24 and 76). But then I get a lot of errors like this one
This code is working totally fine. Right now, I'm trying to update a specific data from the student info. Let's say I'm trying to update my student number of Daniel. So, in this case, I want to replace 6744590 to some other student number. I think I have to use fseek() or rewind() and use fputs() but, I don't know how I should decide where to look.
How would one go about doing this? I am very fond with Windows I/O, but not so much with this subject. I am decent with fstream, probably not as skilled at it as I should be, but I assume <fstream> would be a better choice, since it isn't locked to Windows.
Anyway, say I have a .txt file like this:
Bill is a cow. Bill likes meat. Bob is a pig. Bob and Bill are friends.
And I want to count the number of times "Bill" is written. How would I do that?
For my intro to c programming class, our homework requires us to read a data file and emit various bits of information. the data file looks like this
#Domain: the URL #Alexa: some kind ranking, small numbers are better #Rank: another sort of ranking, big numbers are better
#Domain Alexa Rank Site Name #------------ ----- ------- --------- amazon.com 13 1177136 Amazon.com google.com 1 4533883 Google youtube.com 3 3637788 YouTube
[Code] ....
I've started and am able to get the correct number of lines, and the alexa number, but I keep getting some errors and am just unsure where to correct my code. This is what it looks like;
Code: // Lexi Anderson //CS 156 #include <stdio.h> int main() {
I was trying to make a program in C that could take Personality Information from the user and store it in a text file. Then, when asked, could compare the results to other entries in the so called "data-base" and tell which is the best match. I tried a whole lot but couldn't think of a proper way.
(Stings and File IO are not my strong points)
I am using Code Blocks 10.05 and the standard GCC compiler.
So I have to read from a file, and store the information in separate variables. My problem is that for some of the information I need multiple words, and for others I don't, so I cant simply store 1 word into a variable and store the next in another in so on. To demonstrate what I mean let me give an example.
Dog Cat Blue Bird Snake White Horse
I am able to store "Dog","Cat","Blue","Bird"...etc in variables but I don't know how to make it so I can store "Dog" in one variable, "Cat" in a second variable. and "Blue Bird" in a third variable. "Snake" would be the 4th and "White Horse" would be the fifth. How can I read a file and manipulate the pointer to grab what I need?