//window is an HWND
LPWSTR path = new WCHAR[1024];
DWORD size = 1024;
GetWindowText(window, path, 1024);
HINSTANCE instance = (HINSTANCE)GetWindowLongPtr(window, GWLP_HINSTANCE);
QueryFullProcessImageName(instance, PROCESS_NAME_NATIVE, path, &size);
This code fails on the call to QueryFullProcessImageName(...) with an error code 6 ...
I am writing a text renderer for an OpenGL application. Size, colour, font face, and anti-aliasing can be twiddled at run time (and so multiple font faces can appear on the screen at once). There are too many combinations to allocate one texture to each combination of string and attributes. However, only a small subset of the entire d...
Say I wanted to do an anonymous login, would it be to blank strings.
"" ""
?
...
struct ast_channel *(* const requester)(const char *type, int format, void *data, int *cause);
what is the meaning of this line?
what is the advantage of using
static struct hello
{
int a;
chat b;
};
over simply
struct hello
{
int a;
};
also difference between static char p[]and char p[];
As i am very new to c pro...
Hello,
linux gcc c99
I am wondering what would be the best technique. To change a string. I am using strstr();
I have a filename called "file.vce" and I want to change the extension to "file.wav".
Is this the best method:
char file_name[80] = "filename.vce";
char *new_file_name = NULL;
new_file_name = strstr(file_name, "vce");
strnc...
Platform: ARM9
Programming Language C
Requirements - plain C and no external libs and no boost.
OS - REX RTOS
I have two threads running in an embedded platform -
one is at driver level handling all the comms and data transfer with the hardware.
the second thread runs the application that uses the data to/from the hardware.
Th...
int fn();
void whatever()
{
(void) fn();
}
Is there any reason for casting an unused return value to void, or am I right in thinking it's a complete waste of time?
Follow up:
Well that seems pretty comprehensive. I suppose it's better than commenting an unused return value since self documenting code is better than comments. P...
One such program that uses a wait function like this is this one:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int pid,fd[2]; int n; char line[20];
if(pipe(fd)<0) {
printf("Error creating pipe");
} else {
pid=fork();
if(pid<0) {
printf("Error while forking");
} else {
if(pid>0) {
close(fd[0]);
...
I've been a programmer for years now and I feel very comfortable in a handful of languages, especially C.
What I find baffling is that while I have no problem reading code from textbooks and example sites, no matter what the code is doing, I find that when I check out an open source project and look at the code, it almost looks like a f...
Have a look at this code:
#include <iostream>
using namespace std;
int main()
{
const char* str0 = "Watchmen";
const char* str1 = "Watchmen";
char* str2 = "Watchmen";
char* str3 = "Watchmen";
cerr << static_cast<void*>( const_cast<char*>( str0 ) ) << endl;
cerr << static_cast<void*>( const_cast<char*>( str1 ) )...
Or do you just have to do it and check errno and/or the pointer to see if you succeeded?
...
Hi,
in the following piece of code, I see that when my 'description' is something like:
" ' ' ", I have a problem updating the description to the sqlite record.
How do i handle the ' character. thanks!
sql = wxString::Format(
"UPDATE event SET event_description='%s' WHERE id=%d",
description.c_str(),
event_id);
rc = sqlite3_...
Hi,
I need some help rewriting the following line in a more type safe way and rewriting it as a function, however the fact that this code is defined inside a function is making it hard for me to think of a clever way of doing it because apparently it would involve declaring several arguments.
#define CHECK(id) if(table->cells[id]) isgoo...
I have a program running as root on Linux, talking to a tty (actually an LCD implemented as a tty). The device for what it's worth is /dev/ttyUSB0. I'd like to have my program that writes to this device be able to have exclusive access to the device, so as to not have any interference from other instances of the program running at the sa...
Very general:
Is there an easy way to tell which line of code last freed a block of memory when an access violation occurs?
Less general:
My understanding of profilers is that they override the allocation and deallocation processes. If this is true, might they happen to store the line of code that last freed a section of memory so that...
I'm currently working on a C based application am a bit stuck on freeing memory in a non-antipattern fashion. I am a memory-management amateur.
My main problem is I declare memory structures in various different scopes, and these structures get passed around by reference to other functions. Some of those functions may throw errors and e...
As I posted earlier here I've decided to try my hand at one of these but given my interests as a web developer, I'd like to know the difference between them in their real-world applications.
Edit Note:
While I'm a web developer, please don't let that limit your answer. I'm 30...I've got years of career changing ahead of me.
...
I've written a library to match strings against a set of patterns and I can now easily embed lexical scanners into C programs.
I know there are many well established tools available to create lexical scanners (lex and re2c, to just name the first two that come to mind) this question is not about lexers, it's about the best approach to "...
Is it possible to dereference the void pointer without type-casting in C programming language?
Also, is there is any way of generalizing a function which can receive a pointer and store it in void pointer and by using that void pointer we can make a generalized function?
for e.g.
void abc(void *a, int b)
{
if(b==1)
printf("%d...
Hello,
I have a very basic question and need help.
I am trying to understand what is the scope of a dynamically allocated memory (on heap).
#include <stdio.h>
#include <malloc.h>
//-----Struct def-------
struct node {
int x;
int y;
};
//------GLOBAL DATA------
//-----FUNC DEFINITION----
void funct(){
t->x = 5; //**can I...