Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

using namespace std;


Rekomendowane odpowiedzi

Opublikowano

nie ma czegoś takiego jak string.h. po prostu <string>

 

#include <allegro.h>
#include <winalleg.h>
#include <string>
inline void init()
{
allegro_init();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 300, 150, 0, 0);
install_timer();
install_keyboard();
install_mouse();
enable_hardware_cursor();
select_mouse_cursor(MOUSE_CURSOR_ARROW);
show_mouse( screen );
unscare_mouse();
}
inline void deinit()
{
clear_keybuf();
allegro_exit();
}
int main()
{
init();
BITMAP* bufor = NULL;
bufor = create_bitmap(SCREEN_W,SCREEN_H);
  std::string tekst;
tekst = "buba";
while (!key[KEY_ESC])
{
	clear_to_color(bufor,makecol(210,210,210));
	textout_ex(bufor, font,tekst,10,10,makecol(255,255,255),-1);
	draw_sprite(screen, bufor, 0, 0);
}
deinit();
return 0;
}
END_OF_MAIN()

lub

#include <allegro.h>
#include <winalleg.h>
#include <string>
using namespace std;
inline void init()
{
allegro_init();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 300, 150, 0, 0);
install_timer();
install_keyboard();
install_mouse();
enable_hardware_cursor();
select_mouse_cursor(MOUSE_CURSOR_ARROW);
show_mouse( screen );
unscare_mouse();
}
inline void deinit()
{
clear_keybuf();
allegro_exit();
}
int main()
{
init();
BITMAP* bufor = NULL;
bufor = create_bitmap(SCREEN_W,SCREEN_H);
  string tekst;
tekst = "buba";
while (!key[KEY_ESC])
{
	clear_to_color(bufor,makecol(210,210,210));
	textout_ex(bufor, font,tekst,10,10,makecol(255,255,255),-1);
	draw_sprite(screen, bufor, 0, 0);
}
deinit();
return 0;
}
END_OF_MAIN()

w drugim jest using namespace

Opublikowano

Muszę cię zmartwić: Pobierałem ok 2 tyg temu i również mam 10.05 :) więc nie wiem czemu mi znikła biblioteka.

 

@edit

Biblioteka jest:

C:\Program Files (x86)\CodeBlocks\MinGW\include\string.h

Więc ni wim o co kaman.

 

@edit2

A jak dodam .h to normalnie działa ale wywala error przy using namespace std;

C:\Users\Piotrek\Desktop\Pliki\Projekty\Bounce\main.cpp|4|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'|
C:\Users\Piotrek\Desktop\Pliki\Projekty\Bounce\main.cpp||In function '_mangled_main':|
C:\Users\Piotrek\Desktop\Pliki\Projekty\Bounce\main.cpp|57|error: 'string' undeclared (first use in this function)|
C:\Users\Piotrek\Desktop\Pliki\Projekty\Bounce\main.cpp|57|error: (Each undeclared identifier is reported only once|
C:\Users\Piotrek\Desktop\Pliki\Projekty\Bounce\main.cpp|57|error: for each function it appears in.)|
C:\Users\Piotrek\Desktop\Pliki\Projekty\Bounce\main.cpp|57|error: expected ';' before 'tekst'|
C:\Users\Piotrek\Desktop\Pliki\Projekty\Bounce\main.cpp|61|error: 'tekst' undeclared (first use in this function)|
||=== Build finished: 6 errors, 0 warnings ===|

Opublikowano

W kodzie, który wkleiłeś, nie widzę żadnej linii "using namespace std;".

 

Wklej kod, któy zawiera takową linię i który wywala podany przez ciebie błąd.

Ta sygnatura jest pusta.

Opublikowano

@up

Tak jest na każdym kodzie, nie mogę uruchomić podstawowego "Hello World".Usunąłem Code:Blocks, Zainstalowałem -> nowy projekt konsolowy -> c++ -> http://wklej.org/id/705458/ -> F9 ->

||=== test, Release ===|
C:\Users\Piotrek\Desktop\Pliki\test\main.cpp|1|error: iostream.h: No such file or directory|
C:\Users\Piotrek\Desktop\Pliki\test\main.cpp|3|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'|
C:\Users\Piotrek\Desktop\Pliki\test\main.cpp||In function 'main':|
C:\Users\Piotrek\Desktop\Pliki\test\main.cpp|7|error: 'cout' undeclared (first use in this function)|
C:\Users\Piotrek\Desktop\Pliki\test\main.cpp|7|error: (Each undeclared identifier is reported only once|
C:\Users\Piotrek\Desktop\Pliki\test\main.cpp|7|error: for each function it appears in.)|
C:\Users\Piotrek\Desktop\Pliki\test\main.cpp|7|error: 'endl' undeclared (first use in this function)|
||=== Build finished: 6 errors, 0 warnings ===|

 

Męczę się z tym już 4 dni i 0 efektu. W katalogu:

C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++

Plik "iostream" JEST.

 

 

@edit

w kodzie usunąłem .h , a w search directories dodałem:

C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++

I poszło ! Ale .....

 

 


C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iostream|39|error: bits/c++config.h: No such file or directory|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\stringfwd.h||In function '_GLIBCXX_BEGIN_NAMESPACE':|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\stringfwd.h|44|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\stringfwd.h|47|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\stringfwd.h|50|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\stringfwd.h|54|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\stringfwd.h|56|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\stringfwd.h|75|error: expected declaration specifiers before '_GLIBCXX_END_NAMESPACE'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\stddef.h|211|error: storage class specified for parameter 'size_t'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\stddef.h|323|error: storage class specified for parameter 'wchar_t'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\cstddef|49|error: expected declaration specifiers before '_GLIBCXX_BEGIN_NAMESPACE'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\cstddef|52|error: expected declaration specifiers before 'using'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\cstddef|54|error: expected declaration specifiers before '_GLIBCXX_END_NAMESPACE'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\cwchar|65|error: expected declaration specifiers before '_GLIBCXX_BEGIN_NAMESPACE'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\cwchar|69|error: expected declaration specifiers before '_GLIBCXX_END_NAMESPACE'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\postypes.h|98|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'streamsize'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\postypes.h|111|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\postypes.h|207|error: expected declaration specifiers before ';' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\postypes.h|214|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\postypes.h|219|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\postypes.h|228|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\postypes.h|230|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits\postypes.h|239|error: expected declaration specifiers before '_GLIBCXX_END_NAMESPACE'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|49|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|52|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|55|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|58|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|61|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|65|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|69|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|73|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|77|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|80|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|83|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|86|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|89|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|92|error: expected declaration specifiers before 'template'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|97|error: expected declaration specifiers before 'class'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|127|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|128|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|129|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|130|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|131|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|132|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|133|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|134|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|135|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|136|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|137|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|138|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|139|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|

 

 

 

Więc nadal czekam na propozycje :P

Opublikowano

@up

Ke ? Ty wiesz co to jest void ? void to jest typ .... NIC

 

int przechowuje liczby

char przechowuje znaki

void przechowuje NIC, służy np. do robienia funkcji które nic nie zwracają.

 

@edit

Sfrustrowany zacząłem szukać innego IDE, na dobreprogramy znalazłem Dev-c++ ..... 5.1 ! Ostatnio zaaktualizowane miesiąc temu ! Czyli że Dev powraca :), po zainstalowaniu wsio działa więc póki nie odkryję problemu z C:B korzystam z dev'a

Opublikowano
Ostatnio zaaktualizowane miesiąc temu ! Czyli że Dev powraca

ale i tak to jest gówno

 

Czy mi sie wydajeze w c++ nie uzywa sie void..???

pare lat temu tak

 

int przechowuje liczby

 

char przechowuje znaki

jakby się przyjżeć bliżej to każdy typ przechowuje liczby. A to, że widzisz znak, jest tylko jej interpretacją

Opublikowano

Settings > Compiler and Debugger

 

Zaznacz GNU GCC Compiler

zakładka Toolchain Executables > Compiler's Instalation Directory uzupełniasz "C:\Program Files (x86)\CodeBlocks\MinGW" ( wg. tego, co napisałeś, że gdzie zainstalowałeś )

Następnie sprawdzasz, czy wszystkie .exe'ki poniżej są poprawnie poustawiane ( C compiler, C++ compiler, linker for dynamic libs i tak dalej - domyślne ustawienie jest poprawne, chodzi mi tylko o to, żebyś powiedział, czy cokolwiek tam jest )

 

Następnie wyczyść wszystkie path'y jakie masz ustawione w search directories.

 

Jeśli wciąż nie będzie działać:

 

W Search Directories dodaj następujące ścieżki:

Compiler: C:\Program Files (x86)\CodeBlocks\MinGW\include

Linker: C:\Program Files (x86)\CodeBlocks\MinGW\lib

 

Oraz, najważniejsze i przede wszystkim, sprawdź z jakiej wersji MinGW (myślisz, że) korzystasz i jaką masz zainstalowaną.

Ta sygnatura jest pusta.

Opublikowano

Settings > Compiler and Debugger

 

Zaznacz GNU GCC Compiler

zakładka Toolchain Executables > Compiler's Instalation Directory uzupełniasz "C:\Program Files (x86)\CodeBlocks\MinGW" ( wg. tego, co napisałeś, że gdzie zainstalowałeś )

Następnie sprawdzasz, czy wszystkie .exe'ki poniżej są poprawnie poustawiane ( C compiler, C++ compiler, linker for dynamic libs i tak dalej - domyślne ustawienie jest poprawne, chodzi mi tylko o to, żebyś powiedział, czy cokolwiek tam jest )

 

majy.png

 

Następnie wyczyść wszystkie path'y jakie masz ustawione w search directories.

Clearnąłem.

 

WTF

Powiem tyle: Jesteś bogiem ! Przecie juz tak robiłem ! I nie działało ! A teraz sprawdzam i buczy !

Wielkie dzięki, jak fajnie wrócić do C:B.

 

Dzięki wszystkim

:)

Opublikowano

What else is new...

 

Rozumiem, że przekopiowałeś te dwie odpowiednie linie do Linker and Compiler w Search Directories, tak?

Ta sygnatura jest pusta.

  • 3 tygodnie później...

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...