- Strength to Increase Rep
- +5
- Strength to Decrease Rep
- -1
- Upvotes Received
- 6
- Posts with Upvotes
- 6
- Upvoting Members
- 5
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Langs: C, C++, Python, x86 assembly and a bit of Java
53 Posted Topics
Re: Some plov and a glass of coke. Plov is like a russian meal containing rice, grated carrots and meat cut into chunks. [url]http://www.gumbopages.com/food/russian/plov.html[/url] | |
Re: You don't have to loop through every byte read. You can do [CODE]fread(&(fname->data), sizeof(char), text_length, fptr);[/CODE] if you know the amount of characters in the file. Otherwise you can do [CODE] int i = 0; while(!feof(fptr)) { fread((&(fname->data)) + i, sizeof(char), 1, fptr); i++; } [/CODE] Remember that you must … | |
Re: In your fragment shader (the uncommented lines) you're only calculating ambient color, which could give you the first and the second result (depending on input). This means you're not using normals at all. Also, have you checked the compilation log? Also take a look at how VBO drawing is done … | |
Re: C section would be more appropriate for OpenGL. > I am unable to understand 4th point (i have called glpushmatrix and glpopmatrix in it) but how it is going to update my scene glPush/PopMatrix modifies an internal OpenGL matrices stack. You switch between different stacks with glMatrixMode. glTranslate/Rotate/Scale affect the … | |
Re: You did not link the library. Check your project settings. | |
Hello I'm not new to C++ programming, but I have a question for you guys and gals :) So the code below compiles fine (due to that ugly workaround in main func), but that makes d_copy.field2 unitialized (0xCC bytes in MSVC). How would you change the code to make d … | |
Re: [url]http://en.wikipedia.org/wiki/Pointer_(computing)#C_pointers[/url] You must allocate space in memory for an integer. [CODE]int *n = NULL, m; n = malloc(sizeof(int)); // also check if n isn't null here *n = 5; m = 2; *n = m; free(n);[/CODE] | |
Re: Most operating systems use a second language (C would be the most popular) and as little assembly as possible (for portability to other architectures). Windows is an example of an OS written in C (and assembly for certain parts of its kernel). Linux is also a kernel written mostly in … | |
Re: Some people like to keep their macros upper case, so they won't be confused with variable names. But generally that doesn't matter. It also doesn't matter whether you use long names for macro 'parameters'. When you use macros in your code, preprocessor does this: Original code: [CODE]#define SQUARE(blabla, blablabla) (blabla … | |
Re: This is a correct way to do it: [CODE] int buflen = 1024; char *buffer = NULL; char *readbytes = NULL; int ret = -1; buffer = new char[buflen]; // you have to allocate memory for the buffer ret = recv(a, buffer, buflen, NULL); if(ret == -1) { // an … | |
Re: A simple workaround (you forgot to add a HWND parameter to the window proc): system.h [code] #ifndef SYSTEM_H #define SYSTEM_H #include "stdinc.h" class System { private: void initD3D (void); void cleanD3D (void); void setUpHWND (HINSTANCE, LPSTR, int); HWND window; WNDCLASSEX windowClass; LPDIRECT3D9 d3d; LPDIRECT3DDEVICE9 d3ddev; HINSTANCE hInstance; LPSTR lpCmdLine; int … | |
Re: Read this and look at the example: [url]http://www.cplusplus.com/reference/clibrary/cstdlib/srand/[/url] | |
Re: You have to flush or close the stream to write data to the file. [url]http://www.cplusplus.com/reference/iostream/ostream/flush/[/url] [url]http://www.cplusplus.com/reference/iostream/fstream/close/[/url] | |
Re: To accept connections you also have to call listen ([url]http://www.mkssoftware.com/docs/man3/listen.3.asp[/url]). The thread that called accept will be waiting until it receives a connection. If the socket receives a connection, it will return. If it returns -1, then an error has occured. Otherwise a connection was established/accepted and it will return … | |
Re: You could say that. Dll's contain many 'export' functions and headers help to 'import' them into your application (if the libraries are linked to your application). Those headers also contain necessary definitions (structs and macros). | |
Re: Add a scanf for last name after the first name. [CODE] //... char name[20], lastname[20]; printf("Employee Name:\t\t\t"); scanf("%8s", &name); scanf("%8s", &lastname); //... printf("\n\tEmployee Name: %s %s\t\t", name, lastname); //... [/CODE] | |
Ok, first of all, I'm not sure if this belongs to C section. Since WinAPI is written in C, I'll post here. I'm using OpenGL with Win32 windows (not sure how to call that). I can't switch to fullscreen mode after creating the window. I'm using Windows 7 (64-bits) and … | |
Re: In general: C++ concepts: object oriented programming (OOP) Other: OpenGL/DirectX, math, good programming skills (and habits) What you need to know depends on what you want your engine to do. Is it going to be a 2D or a 3D engine? Do you want physics? Do you want to use … | |
Re: First of all, you aren't stupid for wanting to know that. Curiosity is a good thing, because it helps you learn new things :) The CPU processes machine code. The machine code is (obviously) architecture specific (there are many architectures, like x86 or x86_64). An assembler or a compiler translates … | |
Re: Maybe you didn't link the Allegro library to your executable. What linker are you using? Microsoft linker or GNU (binutils) linker? Are you using Visual Studio? | |
Re: 16. [ICODE]p = scrambleArr(&a[0], 7, sizeof(int), &func);[/ICODE] 27. [ICODE]int *p = &index[0];[/ICODE] | |
Re: 1. [ICODE]stdin[/ICODE] is a file descriptor for console input, thus you can't use it to read from a file. You have to open a file with fopen(). For example: [CODE] //... FILE* f = fopen("file.txt", "r"); fgets(text, MAX_WORDS, f); //... fclose(f); [/CODE] 2. MAX_WORDS is the value of an integer … | |
Re: C is a procedural language. You can imitate C++ classes with C structs. Check this out: [url]http://home.comcast.net/~fbui/OOC.html[/url] | |
Re: Looks like you're missing some library (DLL). | |
Re: I'll just ignore the post above. What do you mean "create a RAM disk"? (RAM isn't a disk...; it stands for Random Access Memory) | |
Re: You can't display more than 256 different colors at the same time with VGA. I found a site which says that you can display 262144 (2^18; 6 bits each for red, green and blue) colors with VGA (that means you will have to modify the palette to display other colors). … | |
Re: [ICODE]price < 0.0f[/ICODE] isn't right. Have you ever seen a book that costs 0$? :P You'll have to show us more code. Btw, those aren't called functions. Those are called methods (the first one is a constructor). | |
![]() | Re: I think [ICODE]BYTE arrayOfByte[];[/ICODE] (add a semicolon...) would be a pointer too (I'm not sure because I've never used [] instead of a pointer). The rest of your code: [CODE] int main() { BYTE arrayOfByte[]; BYTE *ptrToArray = arrayOfByte; //... someFunc(ptrToArray); //... return 0; } void someFunc (BYTE *foo) { … ![]() |
Re: [QUOTE=Buffalo101;1524984]C++: [url]http://www.daniweb.com/software-development/cpp/threads/134017[/url][/QUOTE] C != C++ Linux, IPv4: [CODE] #include <netdb.h> #include <sys/param.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> int main(int argc, char** argv) { hostent * record = NULL; in_addr* address = NULL; char* ip_address = NULL; if(argc != 2) { printf("usage: %s <hostname>\n", argv[0], argv[1]); return 1; } record … | |
Re: Since you've posted in C section (not the best section to post things like that), I assume you want to start learning C. C++ is also an option. Once you're experienced with C/C++, it's easy to learn an another language (I found that easy). There are stickies on forums, like … | |
I'm writing a pure C game engine. I assert every pointer returned by malloc() in my code. Now I'm writing a function that will "slice" a loaded texture into new textures (parts of the parent texture). The parent texture is loaded correctly (other textures loaded by the same loader were … | |
Re: (1) Server must send (write()) the bytes to the client (make sure the client is aware that he is going to receive those bytes and knows what to do with them). (2) Server must recognize (read()) "pwd" and "dir" so it can respond to client sending (write()) back a message … | |
Re: You can get some information about OS development here: [url]http://wiki.osdev.org/Main_Page[/url] . | |
Re: Just add a line to your .rc file: [CODE] ANY_NAME_FOR_THE_RESOURCE ICON "your_icon.ico" [/CODE] Works for just any app I compile. Btw, the question you asked has nothing to do with GDI. | |
Re: You could try LoadLibrary and GetProcAddress from Windows API. LoadLibrary: [url]http://msdn.microsoft.com/en-us/library/ms684175(v=VS.85).aspx[/url] GetProcAddress: [url]http://msdn.microsoft.com/en-us/library/ms683212(v=VS.85).aspx[/url] It's very simple. [CODE] HMODULE DLL = LoadLibrary("SomeDLL.dll"); void (*DLLFunction)() = GetProcAddress(DLL, "DLLFunction"); [/CODE] You have to know the return type and argument types of a loaded function (procedure). | |
Re: I have noticed one thing pretty weird in your code (the last bit). Why did you put an if-statement into a switch body? I bet that is the problem. Only use case's and default in your switch body. One word of warning. It's an English forum. If you're posting some … | |
Re: This [CODE] // sprite.h Sprite(SDL_Surface* surface, SDL_Rect frames[]); // sprite.cpp Sprite::Sprite(SDL_Surface* surface, SDL_Rect frames[]) { ... } [/CODE] could be the problem. Try using SDL_Rect * frames instead of SDL_Rect frames[]. I don't know if that's a solution because I only use OpenGL, hope this helps though. | |
Re: I think you meant to use * instead of x and X? X and x can't be used as operators. | |
Re: On 2008 I remember using my own Microsoft.VC90.CRT.manifest files instead of VC++ redistributable installation. For this you need to get msvcp90.dll and msvcr90.dll. Then you should get info about their version and target architecture. You can get the version number right clicking on the dll file and choosing "Properties". Then … | |
Re: You don't have to define a DLL entrypoint and I don't think you need to use __declspec(dllexport) on *nix (I don't know about static libraries but shared libraries don't need that). | |
I'm writing a small game engine and I have a little problem. The code below shows the exact situation: Header1.h [CODE] #ifndef _HEADER1 #define _HEADER1 #include "Header2.h" namespace HNamespace { class HClass1 { public: HClass1() { } ~HClass1() { } HClass2 * A; }; } #endif [/CODE] Header2.h [CODE] #ifndef … | |
Re: I once made a small kernel just for pure fun. It was very poor and I can really advise you on just one part of it. > Memory management You can use parts (or whole) code from this site: [url]http://www.fourmilab.ch/bget/[/url] I believe it's GPL, find out for yourself. If you … | |
Re: You can just [ICODE]fopen("file", "w");[/ICODE] to create the file if it doesn't exist. You can also try checking if a file exists using dirent.h on *nix, check this out: [url]http://opengroup.org/onlinepubs/007908799/xsh/dirent.h.html[/url] Hope it helps. | |
Re: In my opinion, creating merging the arrays and then sorting the merged array isn't a bad idea because it's simple. But that depends on what you seek - performance or simplicity. Everything is possible to code but depends on your experience and the amount of time to spend doing it. … | |
Re: I had once held a small project for Linux but that was a few months ago, and I hardly remember anything since it was my last project which I wrote for Linux. I mostly program for Windows now, but I'm not going to write my autobiography here! Here's a little … | |
Re: Can you paste the errors you get? And possibly more code? By the first look I can advise to use pointers instead of int seat[][][][]. | |
Re: There are several ways to develop key loggers on Windows. I'll list them in order worst to best: 1. You could GetAsyncKeyState() from W32 API in a loop, but I guess most of the anti-viruses would detect those easily. But it's worth to try if you are a beginner (I … | |
Re: Public is missing a colon, and get() method should look like this: [icode]long get () const { return x; }[/icode] Why do you need set method to be const anyway? | |
Hello everyone, I started learning assembly yesterday. Yes maybe I chose a wrong guide but I have a little problem here. It's about getting some integers without a newline. That is probably very easy to solve but I was searching for a solution for a few hours and no results. … | |
Re: You might want to try something like this, but yes it uses more CPU and memory. [code]#define YOUR_ARRAY_SIZE 256 #include <string.h> char * getName(){ char buf[YOUR_ARRAY_SIZE]; sprintf(buf,name); return &buf[0]; }[/code] |
The End.