Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. need help !!

need help !!

Scheduled Pinned Locked Moved Managed C++/CLI
helpc++tutorialcareerlearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    hi i am kind of new in programming and am still learning c++ , and so far i know about functions arrays pointers and a little about file processing but no knowledge of object and classes... anyway , i've been encountering some annoying problems , and i found out that they're all about the difference between the .h header files and the new ones with the 'using' and namespaces. and here's some of the problems i found : - when i use and for example i store 025 in an integer with cin and then output it with cout i'll get a different value but with and using namespace std; i dont have this problem - while outouting and inputing to a file with and using namespace std; and then passing this file to a recursive function as follows : void func ( ifstream dd ) { ..bla bla func(dd) bla bla.. } ... ifstream file ("ff.txt"); func (file); ... I get errors but with i dont get these kind of errors So if anybody would explain to me (in a simplified way) why i get these errors and if there's a way to do the same job with the new header files cause as you know in early courses they dont explain such things And thanks ==<< ormax3 >>==

    K 1 Reply Last reply
    0
    • L Lost User

      hi i am kind of new in programming and am still learning c++ , and so far i know about functions arrays pointers and a little about file processing but no knowledge of object and classes... anyway , i've been encountering some annoying problems , and i found out that they're all about the difference between the .h header files and the new ones with the 'using' and namespaces. and here's some of the problems i found : - when i use and for example i store 025 in an integer with cin and then output it with cout i'll get a different value but with and using namespace std; i dont have this problem - while outouting and inputing to a file with and using namespace std; and then passing this file to a recursive function as follows : void func ( ifstream dd ) { ..bla bla func(dd) bla bla.. } ... ifstream file ("ff.txt"); func (file); ... I get errors but with i dont get these kind of errors So if anybody would explain to me (in a simplified way) why i get these errors and if there's a way to do the same job with the new header files cause as you know in early courses they dont explain such things And thanks ==<< ormax3 >>==

      K Offline
      K Offline
      kmcguire
      wrote on last edited by
      #2

      #include using namespace std; // cout << [wide range of types] << [wide range of types] << endl; char a = 'a'; int b = 38273; double c = 9382; char * d = "hello"; cout << a << " " << b << " " << c << d << endl; --------------------------------------------------------------------------- #include "stdafx.h" #include #include using namespace std; int main(int argc, _TCHAR* argv[]) { char * OurBuffer = new char[2048]; FILE * FileHandle; ///////////////////////////////////////////////////////////// cout << "Reading from C:\\BOOT.INI, using a " << ( sizeof(char) * 2048 ) << " byte buffer." << endl; ///////////////////////////////////////////////////////////// cout << "Now displaying the file as it is read line by line." << endl; ///////////////////////////////////////////////////////////// ///// EXAMPLE: FileHandle = fopen( "C:\\mydir\\myfile.txt", "r" ) FileHandle = fopen( "c:\\boot.ini", "r" ); while( OurBuffer[0] != 0 ) { ///////////////////////////////////////////////////////////// OurBuffer[0] = 0; fgets( OurBuffer, 2048 * sizeof(char), FileHandle ); cout << OurBuffer; ///////////////////////////////////////////////////////////// } ///////////////////////////////////////////////////////////// return 0; } --------------------------------------------------------------------------- Get a string from a stream. char *fgets( char *string, int n, FILE *stream ); wchar_t *fgetws( wchar_t *string, int n, FILE *stream ); Parameters string Storage location for data. n Maximum number of characters to read. stream Pointer to FILE structure. Return Value Each of these functions returns string. NULL is returned to indicate an error or an end-of-file condition. Use feof or ferror to determine whether an error occurred. --------------------------------------------------------------------------- Open a file. FILE *fopen( const char *filename, const char *mode ); FILE *_wfopen( const wchar_t *filename, const wchar_t *mode ); Parameters filename Filename. mode Type of access permitted. Return Value Each of these functions returns a pointer to the open file. A null pointer value indicates an error. ----------------------------------------------------------------------------------------

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups