Go Back  DVD Talk Forum > General Discussions > Tech Talk
Reload this Page >

help i need computer brains (C++)

Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

help i need computer brains (C++)

Old 01-25-03, 07:52 PM
  #1  
DVD Talk Ultimate Edition
Thread Starter
 
Join Date: Feb 2000
Posts: 4,400
Likes: 0
Received 0 Likes on 0 Posts
help i need computer brains (C++)

okay i need to read and write to a file in C++ and i cant seem to figure out how to read from the freaking file :( and its driving me nuts


ok hear is my code so far


[code]std::fstream Str("C:\inout.txt", ios::out);

// Create 1 meg test file on C Drive.
for (int z=0; z< IOREPS; z++)
{
for (int x=0; x < 104858; x++)
{
// need to write something to a file
Str > temp)
{
//read back from file

std::cout
Old 01-27-03, 02:39 AM
  #2  
DVD Talk Platinum Edition
 
Join Date: Oct 1999
Location: South Surrey, BC
Posts: 3,990
Likes: 0
Received 0 Likes on 0 Posts
I think you should try closing the file before you open it for reading.

BTW you'd make it easier for anyone who tries to assist you, by providing a complete piece of code.

The following code worked in VC++ 6.0:

#include "stdafx.h"
#include <fstream.h>
#include <fcntl.h>
#include <io.h>
#include <iostream>

int FileTest();

void main()
{


FileTest();
}


int FileTest()
{
int nResult = 0;
char temp;
const int IOREPS = 5;


fstream Str("C:\\inout.txt", ios:ut);


// Create 1 meg test file on C Drive.
for (int z=0; z< IOREPS; z++)
{
for (int x=0; x < 10; x++); // 104858; x++)
{
// need to write something to a file
Str > temp)
{
//read back from file

std::cout

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.