Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Otvoriti txt fsile preko turbo c++!
Author Message
amce00 Offline
Novi korisnik
*

Posts: 16
Joined: Dec 2009
Reputation: 0
Post: #1
Otvoriti txt fsile preko turbo c++!
Vozdra raja, imam pitanje kako se vrsi otvaranje txt fajlova preko c++.
Evo sta sam ja uradio:

Code:
#include<iostream.h>
#include<fstream.h>
void main()
{
ofstream myfile;
myfile.open ("D:\proba\example.txt", ios::in);
}

Jednostavan je primjer, samo da se ustelim, pa ako moze neko reci jel ovo uredu ili...
(This post was last modified: 02-04-2010 04:41 PM by amce00.)
02-04-2010 03:57 PM
Find all posts by this user Quote this message in a reply
amce00 Offline
Novi korisnik
*

Posts: 16
Joined: Dec 2009
Reputation: 0
Post: #2
RE: Otvoriti txt fsile preko turbo c++!
amce00 Wrote:Vozdra raja, imam pitanje kako se vrsi otvaranje txt fajlova preko c++.
Evo sta sam ja uradio:

#include<iostream.h>
#include<fstream.h>
void main()
{
ofstream myfile;
myfile.open ("D:\proba\example.txt", ios::in);
}

Jednostavan je primjer, samo da se ustelim, pa ako moze neko reci jel ovo uredu ili...


Code:
#include<iostream.h>
#include<fstream.h>
void main()
{
ofstream myfile;
myfile.open ("example.txt");
myfile << "hello";
myfile << 2+3;
myfile.close();
}

ovako skonto sam kad se vrsi preko ios::out, imam ovaj zadatak koji izbacuje eror:

#include <iostream.h>
#include <fstream.h>


void main () {
ofstream myfile ("example.txt");
if (myfile.is_open())
{
myfile << "This is a line.\n";
myfile << "This is another line.\n";
myfile.close();
}
else cout << "Unable to open file";

}

jel grijesim u nardebi nisam skonto, gdje sam pocrvenio tu je error.
(This post was last modified: 02-04-2010 04:42 PM by amce00.)
02-04-2010 04:40 PM
Find all posts by this user Quote this message in a reply
Gogy Offline
____
*

Posts: 2,311
Joined: Feb 2006
Post: #3
RE: Otvoriti txt fsile preko turbo c++!
Zavisi od compilera ali evo meni ovaj kod radi...

Code:
#include <iostream>
#include <fstream>

using namespace std;

int main ()
{
   ofstream myfile ("example.txt");
   if (myfile.is_open())
   {
      myfile << "This is a line.\n";
      myfile << "This is another line.\n";
      myfile.close();
   }
   else cout << "Unable to open file";

   return 0;
}

Pravila foruma | Twitter - Facebook - Google+ |


Radar404 <- moj blog
03-04-2010 12:12 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)