Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

warum kann folgender Code nicht richtig im C++ Builder compiliert werden???

Es tretten immer wieder Fehler auf, wenn ein File-Stream geöffnet werden soll auf

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include <iostream.h>

#include <istream.h>

#include <fstream.h>

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

SIZE z;

// hier, kann nicht compiliert werden ... :(

ostream out("test",ios_base::in|ios_base::out);

cout << "test";

GetTextExtentPoint32(

GetDC(Edit1->Handle),

Edit1->Text.c_str(),

strlen(Edit1->Text.c_str()),

&z);

Label1->Caption = z.cx;

Label2->Caption = z.cy;

}

//---------------------------------------------------------------------------

es kommt immer die Fehlermeldung:

[C++ Error] Unit1.cpp(24): E2285 Could not find a match for 'ostream::basic_ostream(char *,int)'.

[C++ Warning] Unit1.cpp(36): W8004 'out' is assigned a value that is never used.:confused: :confused: :confused: :confused:

da mein Problem, denke ich ganz gut zudem Thema passt, poste ich es mal hier rein.Ich habe eine Funktion, in der möchte ich eine textdatei, zeilenweise auslesen, die Funktion schaut so aus:

-----------------------------------

void SNMPSystem::get_SNMPSystem(void)

{

SNMPSystem ss;

int pos,position, zaehler,bedingung;

ifstream einlesen("/home/dirk/mysnmp/cpp_snmp/snmp.conf");

if (!einlesen)

{

cerr << "Fehler: Datei kann nicht geoeffnet werden!\n";

}

while(!einlesen.eof())

{

einlesen.getline(ss.zeile,250);

cout << "\n" << ss.zeile;

}

}

-------------------------------------------------

beim ausführen des Programms bricht es aber immer an folgender Stelle ab mit einem "Speicherzugriffsfehler":

einlesen.getline(ss.zeile,250);

Wieso? ss.zeile, ist ein char-pointer der Klasse "SNMPSystem"!

@dirk12345:

Jetzt muss ich aber doch mal fragen, warum in aller Welt Du in einer Member-Funktion Deiner Klasse eine weitere Instanz der Klasse erzeugst, nur um auf den zeile-Member zuzugreifen. Warum nimmst Du nicht den zeile-Member der Instanz, zu der die Funktion gehört?

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.