C/C++ :: How To Read Data After EOF Command Has Been Executed
Mar 26, 2013
I have to write a program in c which allow user store data in a file as well can edit it.... i have written the following program, but the program cannot read data after EOF command has been executed....
#include <stdio.h>
main() {
FILE *fp;
char c;
int ch;
char filename[20];
printf("enter filename");
[Code] ....
View 2 Replies
ADVERTISEMENT
Feb 11, 2013
I want to read sentence from command line. I open some program which run in command line and I have to wait for that program process. So , I don't know when process success .I can't type next command if can't read sentence from command. I use
Code:
wprintf(GetCommandLine());
but it show
"C:UsersPKRUdocumentsvisual studio 2010ProjectsVirus ScanDebugMyProgram
How to read sentence from Command line with MFC?
View 5 Replies
View Related
Aug 3, 2014
I am having an issue with the statement "Both the input and output files' names should be read from the command line." I don't understand what this means or what I need to do.
View 4 Replies
View Related
Jul 6, 2014
I work currently on the program and I need send a mail. I have a problem with a data SMTP command. Indeed, this command return this error message:
503 5.5.0 <DATA>: Data command rejected: Improper use of SMTP command pipelining
This is my source code (just the interesting part ;)):
char data[] = "HELO smtp.yopmail.com
"
"MAIL FROM:<test@gmail.com>
"
"RCPT TO:<zaegffhgjhgfghjtertfgd@yopmail.com>
"
[Code] .....
I don't understand why it don't work because the same command work when I use it manualy in console. I'm on Ubuntu ....
View 11 Replies
View Related
Mar 5, 2013
I am trying to write a simple program that produces different outputs based on entered age of two different users. Program should tell who is older and behave different if both users are older than 100.
Here is my program: Code: #include <iostream>
using namespace std;
int main()
{
[Code].....
Why program executes this when both users are obviously more than 100
View 8 Replies
View Related
Dec 16, 2014
This is the code i am working on: [URL] .... I had designed a cross platform grep and am revising it to making it more well for lack of a better word understandable, and clear.
The line
while(getline(file, currentLine))
Worked before but now it doesn't.
View 1 Replies
View Related
Dec 26, 2013
I am writing a program where I need to read a byte of char data and convert it into a text string of binary data that represents the hex value...
i.e. The char byte is 0x42 so I need a string that has 01000010 in it. I've written the following subroutine....
------------- My Subroutine ----------------------------------------------------------------------
void charbytetostring(char input, char *output){
int i, remainder;
char BASE=0x2;
int DIGITS=8;
char digitsArray[3] = "01";
[Code] ....
When I submitted the byte 0x42 to the subroutine, the subroutine returned to the output variable 01000010... Life is good.
The next byte that came in was 0x91. When I submit this to the subroutine I get garbage out.
I am using a debugger and stepped through the subroutine a line at a time. When I feed it 0x42 I get what I expect for all variables at all points in the execution.
When I submit 0x91 When the line remainder = input % BASE; gets executed the remainder variable gets set to 0xFFFF (I expected 1). Also, when the next line gets executed..
input = input / BASE; I get C9 where I expected to get 48.
My question is, are there data limits on what can be used with the mod (%) operator? Or am I doing something more fundamentally incorrect?
View 6 Replies
View Related
Feb 4, 2013
Code:
#include <stdio.h>
main() {
int c, n1;
n1 = 0;
while ((c = getchar()) != EOF)
if (c == '')
++n1;
printf("%d", n1);
}
I have a more complicated program I'm wishing to have display the output, however, to save some time I'm using an example of a shorter version. count the lines in input and display the output in terminal when ./program is executed after compilation. To count and compute lines, words and within arrays.
View 4 Replies
View Related
Feb 15, 2013
I am facing a problem in C++,I want to execute a command in Command prompt from a specific path.I am able o select a path and execute cmd.exe using the function ShellExecute but the problem is after selecting the path I am not able to execute the command, the command is appearing on another command prompt.
View 4 Replies
View Related
Oct 8, 2013
struct receivers
{string fname, lname, team,;
int receptions, yards, TDs, longest,rec20, fumbles, yac, firstdown;
double, averagepergain, averageperrec
}
View 2 Replies
View Related
Dec 22, 2013
My program needs to receive data continuously from one process and the received data is read continuously by another process.But when I am trying to create a pipe using mknod on fat32 file system in linux , it throws an error saying "mknod: operation not permitted".
View 3 Replies
View Related
Feb 25, 2013
I wanna read a txt file like this
1.00518 2.01903 3.01139 4.01343 5.02751 5.99913 7.00011 7.99851 .....
and fill the array P[i][j] with the data.
I try to use
if (myfile.is_open()) {
//for (int i = 0; i < 1; i++)
//{
getline (myfile,DMArray[0]);
cout << DMArray[i] << endl;
//}
myfile.close();
}
But this read the data into a string. How should i do with this string. Besides I know the dimension of the data I am reading.
View 1 Replies
View Related
Oct 30, 2013
My function is only reading the first line of numbers even though I have the loop to keep returning to it in main(). How do I have it read from the file until it runs out of data to retrieve?
File being read
90 83 94
72 65 81
File being sent the data(Only the second average is correct, working on the first)
Student Information
Student IDGradeAverageLetter Grade
1895612
90 83 94
289
90 83 94
#include <fstream>
#include <iostream>
using namespace std;
ifstream infile;
ofstream outfile;
void grades(int&,int&,int&); // Grades from the input file
int myavg(int,int,int); // Calculates the Average of the 3 grades
[Code] .....
View 8 Replies
View Related
Dec 5, 2014
I am a member of a group still developing the Microprose European Air War game. We have the source code and permission to do this. As the code dates back to 1998 I use Visual Studio 2006.
I have written many programs in Visual basic, and have the following one to read the airbase value in the "targets.dat" file. The file has a four byte header containing the number of tatgets, and a 32 byte data block containing the data for each target.
Private Sub Command1_Click()
List1.Clear
Dim nt As Long
Dim a4() As Long
Open App.Path & " argets.dat" For Binary Access Read As 1
'read and display the number of targets
[Code] ....
Despite many attempts I cannot write the C equivalent of this code into the eaw.exe source. All I really need to know is how to open the 'targets.dat' file and how to get the value of a byte (or integer, or long) at a given position as in the "Get #1, k, a4(n)" line.
View 1 Replies
View Related
Jul 1, 2013
Code:
#include <stdio.h>
#include<ctype.h>
void try5t(){
char choice;
int choiceint;
[Code] .....
Loop is repeated an additional time as shown in the screenshot:
View 9 Replies
View Related
May 7, 2013
i write this program and every things work correct except when i want to add data of file to the link list .when i add the data to the link list by add_to_linked_list() every things work correct but when i use read_linked_list_from_file() it doesn't work
Code:
#include <stdio.h>
#include <stdlib.h>
// double linked list structure
struct linked_list {
struct linked_list *next;
struct linked_list *prev;
char *value;
};
[code]....
View 2 Replies
View Related
Jul 11, 2013
Is there any way to make a switch in C. That I can choose between different data types? For example, at the moment I need to know how to read one parameter. It must recognize if it is a boolean or uint32.
View 4 Replies
View Related
Apr 1, 2013
Trying to do a homework assignment for a class and how to read a file into an array. I've looked in our book and on several other forums and cant seem to find any examples of this. Below is the assignment I'm working on. I have a shell of the program that I can get to run, but getting a .txt file to read into an array is something I cant seem to figure out how to do.
Write a program to read N data items into two arrays, X and Y, of size 20. Store the product of the corresponding pairs of elements of X and Y in a third array Z, also of size 20. Print a three column table that displays the arrays X, Y, and Z. Then compute and print the square root of the sum of the items in array Z. Compute and print the average of the values in array Z and print all values above the average of array Z. Determine the smallest value in each array using only one function.
Use the two data files named DATAX.TXT and DATAY.TXT.
You must use functions for the reading of the data, computing the average, printing the three column table and printing the values above average.
View 3 Replies
View Related
Nov 15, 2014
I am currently working on a problem where I read a file into a 2D array, and display data. If you saw my code earlier, this is the same problem, but I am now further along.
The file (90 characters) looks like this:
S
R
R
S
R
R
R
R
S
S
....
The "R" resembles rainy days, the "S" resembles sunny days, and the "C" resembles cloudy days. There are 90 characters in the file. The first 30 are for the month of June, the next 30 are for the month of July, and the last 30 are for the month of August. The 31st day of the months are NOT included.
I read the data into a 3 x 30 array, where the row indicates the month (0 = June, 1 = July, 2 = August) and the column indicates the number of days in each month.
Now I need to create a function that creates a report and displays, for each month AND for the whole 3 month period:
1) The number of rainy days
2) The number of cloudy days
3) The number of sunny days
4) Which of the 3 months had the largest number of rainy days
Here is my code so far:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int MONTHS = 3;//Number of months
[Code] .....
There are no compiling errors, but I am not getting the data I want. My rCount and cCount variables end up being 0, and my sCount variable is 90.
View 4 Replies
View Related
Jun 21, 2014
I have to read a particular student data from file using his Roll no and modify it and then save it to file again
This is the File
24 salman 98 97 96 95 94 A ;
21 faizan 88 87 86 83 85 B ;
35 Gohar 99 98 97 96 90 B ;
45 sibghat 91 92 78 85 88 C ;
009 john 89 87 91 78 95 C ;
how can i read data of roll no 35 and modify it and save it again to the file
this is my program
int r = 0 ;
while ( ar[j]!="0" ) {
//cout << "Salman majid is
" ;
if ( ar[j]==k ) {
r = j ;
getdata() ;
[Code] .....
View 2 Replies
View Related
Feb 26, 2013
My program reads data from a txt file and it displays the test scores and the sum of the scores, and it also shows the max and min from the scores , so far only one number shows up from the scores instead 10 and i think my sum is wrong too, but i cant get the max and min to work ...
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
void openfile(ifstream &infile);
[Code] .....
View 17 Replies
View Related
May 3, 2014
Assume you want to read from a file and place the data from the file into an array. The array can hold 10 integers. The file may contain any number of integers with 1 integer per line. Fill in the missing loop test condition so that we will read from the file until either end of file occurs or the array is full. Note we are using cin to read from the file since input redirection is being used.
cin >> temp;
arrayIndex = 0;
while ( _____________________________________) {
array[arrayIndex] = temp;
arrayIndex++;
cin >> temp;
}
View 2 Replies
View Related
Jul 23, 2012
How to read a line with maximum of 8 bytes from a line in a file.
Let say line has 10248 bytes in one single line and same repeats for remaining lines in the file.
I need to read the first 8 bytes of a line and go on read the last 2 bytes of the line and repeat the till end of file.
View 3 Replies
View Related
Apr 23, 2013
I have the following method to read in a data file using a struct and a doubly linked list.
The readFile method is as follows:
Code:
struct contact *readFile(char * FName,struct contact **ptrList) {
struct contact *head, *newContact;
FILE *fptr;
char oneLine[60];
char *sname, *fname, *phone,*company, *email;
[Code] .....
My struct definition is like this:
Code:
struct contact {
char sname[15];
char fname[15];
char phone[15];
char company[15];
char email[15];
struct contact *prev;
struct contact *next;
};
View 2 Replies
View Related
Mar 25, 2013
I am trying to read an array values from Tmin.txt file. I take array size from user viz. number of raw & column and then, read the following data from Tmin.txt file which look like this:
20 40 20 25 30
20 30 40 20 25
20 40 20 25 30
20 30 40 20 25
30 40 40 30 40
I am using getline, and then converting it to int by using atoi. But my code is not working.
Code :
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
[Code] ....
View 10 Replies
View Related
Mar 31, 2014
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() {
[Code] .....
and once compiled, I get errors.
View 7 Replies
View Related