C++ :: Fprintf Not Working - Unable To Take Text From A File

Jan 11, 2015

I am trying to take text from a file and have it displayed using fprintf at line 46. When I run the below code nothing prints out. My text file has 4 lines with 5 different strings separated by whitespace.

#include <cstdlib>
#include <vector>
#include <cstring>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
using namespace std;
//declare my own struct

[Code]...

View 7 Replies


ADVERTISEMENT

C :: Unable To Read Data From Text File And Print It

May 12, 2014

I am having trouble in reading data from my text file and print it out exactly like how it looks like in the text file. The problem im having is it will not read the last y Coordinates of the point. it keep reading the second last point for y coordinates which is wrong.

my text file is
0.0 0.0
0.0 1.0
1.0 0.0(but it read until here)
0.0 0.0(suppose to read the last point which is here)

For your information, this is my 1st year degree assignment in C programming. It is to create a program which can read text file (manually create) and print it out in a program and calculate the area for the polygon using ADT function ( .c and .h files)

*This is the code for my read file function*

Basically this accepts a Polygon and a file pointer as parameters. It reads the polygon point data from the file, pass the read data to plg_new() to create a new Polygon and returns the new Polygon created.

Code:

polygon *plg_read(polygon *New_polygon, FILE *Coord) {
int i;
int numberofvertices=0;
int count=0;
char filename[50];
double xCoor[50], yCoor[50];

[Code]....

This is the second function my polygon new code. This ADT function basically creates a new Polygon with malloc(), initialize all ADT data members with its parameter values and returns the Polygon.

Code:

polygon *plg_new(double *xCoordinates, double *yCoordinates, int numberOfVertices) {
int x;
polygon *New_poly = (polygon *)malloc(sizeof (polygon));
if(New_poly->xCoordinates == NULL || New_poly->yCoordinates == NULL) {
free(New_poly);

[Code]....

This is the rest of the code if you need to refer to other codings.

Code:
/**
*@file polygon.c
*@brief Functions for polygon / Struct has polygon numberOfVertices, polygon *xCoordinates and polygon *yCoordinates
*@author: Tan Xian Yao
*@id: 4323440
*@date: 22/04/2014
*/

[Code]...

View 6 Replies View Related

C++ :: Code For Displaying Text File Not Working

Dec 6, 2013

i have turbo c++ 3.0 installed . my program is compiled without error and is running. but when i choose option to display scores in the consol , it hangs . check my code. i have to run this on same compiler. i just want to display all the contenets of text file .

#include<iostream.h>
#include<conio.h>
#include<stdio.h>

[Code].....

View 4 Replies View Related

C++ :: Input / Output Text File Manipulation Not Working

Mar 24, 2013

Why my output screen for this program does not want to stay open. It only opens for a split of a second and it's gone. The program is supposed to take numbers from a input file and display and save the manipulation in the output file. Here is the program.

Code:
#include<iostream>
#include<fstream>
#include<iomanip>
usingnamespace std;

[Code] ....

View 6 Replies View Related

C :: Cannot Seem To Edit File Via Fprintf

Aug 13, 2014

Its my 1st time using fopen,fprintf and others and i cant seem to edit my file via fprintf! Heres my program:

Code:

#include <stdio.h>
#include <stdlib.h>
char letter,check,nought,bleh,hi,a;
int main()

[Code]....

View 2 Replies View Related

C :: Fprintf Does Not Save String To File

Jan 3, 2014

Code:

struct sth {
char* str;
} pt;
}
[code]...

fprintf does not save string to file. How can I put structure into list?

View 9 Replies View Related

C :: Print Multiple Characters To Same File Using Fprintf Function

Nov 5, 2014

I'm new to C and was wondering if it was possible to print multiple characters to the same file using the fprintf function provided in one of the C standard libraries?

View 1 Replies View Related

C# :: Unable To Continuously Read More Lines Of Text

Apr 23, 2014

This code works, but not fully This code reads com ports, when a string is available, I check to see if it contains some keywords defined in array If it does, i print out the string itself.

The problem i am having is that it seems to stop processing the data at some point but I do know that there are more strings to be read. So, it does keep reading more lines of data

using System;
using System.Text;
using System.Collections.Generic;

[Code]......

View 9 Replies View Related

C Sharp :: Unable To Type Into Text Box While Running The Application?

Mar 24, 2013

actually it is the windows application .When i'm running my program it is not allowing me to enter the data into textboxes means the cursor is not appearing

View 1 Replies View Related

C Sharp :: Unable To Change Label Text For Certain Location On Web Form

Dec 7, 2012

I am trying to change label text on button click, the way label.text = "string" work well before but not in this case. I tried to put this on other method and it work..it is just not working on the button that I would like to fire..

C# code :

protected void btnTotalGroupMember_Click(object sender, EventArgs e) {
string s = "there";
string[] words = s.Split(' ');
foreach (string word in words) {
Label1.Text = s;

[Code] ...

View 4 Replies View Related

C++ :: Use Of Fprintf

Feb 28, 2014

i have two variables which are arrays and want them to be written below the other once all the values of one variable is written . how can i do that using fprintf function in c++ ?

View 1 Replies View Related

C# :: Linq To SQL Query Not Directly Working But SQL Result Text Works

Apr 14, 2015

I am trying to query dates between two textbox values converted to datetime in C#. The dates are returning in the correct datetime and no conversion problem exists there.

However when I run the below LINQ to SQL query in C# it returns no enumerable results. But if I take the below code:

DbCommand dc = dbHistoryContext.GetCommand(qryRes);
Console.WriteLine(dc.CommandText);

and get the results as a string of text and cut and paste that into the SQL Server Management studio and execute it - then it works. What do I need to do to search between two dates so that it properly works. The field is of format Date in SQL Server if that matters and the fields being used to pass the information to it are DateTime. The compiler doesn't show any errors but it just doesn't return results.

var qryRes = (from res in dbHistoryContext.tblR
where res.updateddate >= dtDateFrom.Date && res.updateddate <= dtDateTo.Date
select res);

View 8 Replies View Related

C++ :: Unexpected Output From Fprintf?

Feb 11, 2014

I have the following piece of code which should write the contents of my vetor to y file but I am getting a very weird output in my file.

for (int i=0;i<amount;i++) {
fprintf(pFileO,"Case #%d: ",i+1);
for (int j=0;j<words[i].size();j++) {

[Code].....

As you can see this doesn't make sene because the file should also contain the exact same things as the cmd outputs. What's going on here ?

View 1 Replies View Related

Visual C++ :: Cbutton Text Wrap Not Working With Windows Classic Theme

Oct 17, 2013

I'm programming with VS2010, for windows 7. The user likes to use the windows classic theme, and I discovered that BS_MULTILINE style isn't working as I expect. When a button is pressed in the classic theme, it looks like there is a temporary margin added that causes the text to wrap only when the button is pushed. It works fine with any other theme.

View 1 Replies View Related

C++ :: Fprintf / Fclose Was Not Declared In This Scope

May 20, 2013

I have this error - [Error] 'fprintf' was not declared in this scope (line 32)

and this - [Error] 'fclose' was not declared in this scope (line 33)

here's my code.........

1 #include <iostream>
2 using namespace std;
3 #include <windows.h>
4 #include <winuser.h>
5
6 int save (int key_stroke, char *file);

[Code] ......

View 3 Replies View Related

C :: Original Text File / Generate Another File With Text Content In Upper Case

Nov 29, 2014

Code software that, from an original text file, generate another file with the text content in upper case.For exemple:

entrence:

luke
tom
alex

outings:

LUKE
TOM
ALEX

My code so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
}

[code]....

View 2 Replies View Related

C/C++ :: Getting Error - Unable To Get Obj File

Jan 31, 2013

In c++ ., I am getting unable to get obj file error first time i compiled i got the output but during the 2nd time i got this error .....

View 1 Replies View Related

C++ :: Unable To Open / Read DAT File

Nov 8, 2013

Reading a .dat file, i'm unable to open the file. This program is for a Air Quality index detector, the AQI machine records the particle concentration every minute and saves it into new data file for each day. So I need to make this program run every minute and convert the concentration in to the AQI readings.

The filename is of the format "ES642_2013-11-09.dat", where ES642 is the software name of the machine, and rest is the year, month and day. The code here is just for the file reading section:

Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

[Code] .....

View 4 Replies View Related

C++ :: Unable To Find Or Open The PDB File

Mar 28, 2014

Code:

'test.exe': Loaded 'C:UsersPcDocumentsVisual Studio 2010Projects estDebug est.exe', Symbols loaded.
'test.exe': Loaded 'C:WindowsSysWOW64
tdll.dll', Symbols loaded (source information stripped).
'test.exe': Loaded 'C:WindowsSysWOW64kernel32.dll', Symbols loaded (source information stripped).

[Code]...

The thread 'Win32 Thread' (0x2d0) has exited with code 1 (0x1).

The program '[6040] test.exe: Native' has exited with code 1 (0x1). my code is not wrong but there is an error which ı dont understand ...where is my error?

View 1 Replies View Related

C :: Unable To Read TXT File Into 2D Array

Jan 30, 2013

here is my code, I'm trying to read a .txt file into a 2D array... what's wrong with my code?

Code:

#include <stdio.h>
#define INPUT_FILE_GET_NAMES "names.txt"
#define INPUT_FILE_GET_SALES "sales.txt"
#define MAX_ROWS_NAMES 25
#define MAX_COLS_NAMES 20
#define MAX_ROWS_SALES 25
#define MAX_COLS_SALES 6
//Function Declarations
char getNames(char namesArray[][MAX_COLS_NAMES], char filename[]);

[Code]...

View 1 Replies View Related

C++ ::  Unable To Open DAT File For Reading

Nov 9, 2013

Need reading a .dat file, i'm unable to open the file

This program is for a Air Quality index detector, the AQI machine records the particle concentration every minute and saves it into new data file for each day. So I need to make this program run every minute and convert the concentration in to the AQI readings.

The filename is of the format "ES642_2013-11-09.dat", where ES642 is the software name of the machine, and rest is the year, month and day.

The code here is just for the file reading section:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {

[Code] ....

View 5 Replies View Related

C++ :: Unable To Input To Array From A File

Mar 12, 2014

I'm having some problems with Input to an array from a file. I think that i need to make a new array for every instance of the loop but i can't figure out how.

Participator class

void Participator::read(ifstream &stream){
getline(stream, name);
getline(stream, address);
stream >> paid;
}ParticipatorRegister class
void ParticipatorRregister::readFromFile(){

[Code]...

View 1 Replies View Related

C++ :: Unable To Open Include File?

Oct 16, 2013

my programme showing error 'unable to open inclde file ****' i fallowed the general procedure i.e., options-->directories--> ( inclde proper path) still not working..

View 2 Replies View Related

C :: Unable To Read TXT File Into A Linked List

Sep 15, 2014

I've been trying to read a .txt into a linked list in the attached code. I'm running into problems, specifically I'm getting errors on line 41 (curr->word=charTemp. I'm trying to set the word array equal to the charTemp array. I've tried strcpy with no luck .

Code:

#include <stdio.h>#include <stdlib.h>
#include <string.h>
//Struct for linked list
typedef struct node {
char word[25];
struct node *next;
} node;

[Code]...

View 2 Replies View Related

C++ :: Unable To Upload A File To FTP Server With Curl

Aug 6, 2014

I'm trying to upload a file to a FTP server with curl. The problem is that I do not know what to do after I enter the passive mode and open the specified port. I tried to send data with curl_easy_send but it simply hangs.

bool Ftp::Upload(const char *local_fn,const char *remote_fn)
{
int ret;
string ip;
unsigned port;
SendCmd("TYPE I");
// Enter passive mode and get IP & port
if(pasv(ip,port)==false)
return false;

[Code]...

How to send file to the server. And I also suspect I should tell the file size to the server.

View 4 Replies View Related

C/C++ :: Unable To Allocate Memory In Middle Of File

Jan 24, 2013

I created a structure containing two variables of type char.

i.e. char name[64],char details[128];

And a pointer to structure now when I write this name and details to file and now I want to change the particular name.

i.e. To modify then if the stored file name is greater than the entered name then it is erasing the next record line also I need to allocate some memory.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved