c

Using strncat with char array element in C

Hi.. I have get error with the following code and i can't figure it out. char name[]="tolgahan" char result[100]=""; strncat(result,name[1],1); I guess, i need to convert name[1] to string format but i don't now how can i do that. Please help me. Best regards. ...

Appending unique values only in a linked list in C

typedef struct child {int count; char word[100]; inner_list*next;} child; typedef struct parent { char data [100]; child * head; int count; parent * next; } parent; void append(child **q,char num[100],int size) { child *temp,*r,*temp2,*temp3; parent *out=NULL; temp = *q; temp2 = *q; temp3 = *q; char *str; if(*q==NULL) { ...

Benefit of using multiple SIMD instruction sets simultaneously

I'm writing a highly parallel application that's multithreaded. I've already got an SSE accelerated thread class written. If I were to write an MMX accelerated thread class, then run both at the same time (one SSE thread and one MMX thread per core) would the performance improve noticeably? I would think that this setup would help hide...

Remove duplicates in a linked list before adding - C

Hi, My question is about removing duplicates from a linked list. But i want to do it before adding to linked list. struct myStr{int number; mystr *next;} void append(mystr **q,int item) { myStr *temp; temp = *q; myStr *newone; if(*q==NULL)// There should be control of previous elements. Call of keysearch function. { temp = (mySt...

How to write a Python lexical analyser?

I'm trying to write a C module to lexically analyse Python code. How can I do it? ...

If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?

I know Ruby right now, however I want to learn a new language. I am running Ubuntu 10.04 right now but I am going to get a Mac later this summer. Anyways I want something more for GUI development. I was wondering if I should learn C on Ubuntu right now, and then learn Objective-C when I get an iMac? Will learning C give me an edge? Or sh...

Is it secure to use malloc?

Somebody told me that allocating with malloc is not secure anymore, I'm not a C/C++ guru but I've made some stuff with malloc and C/C++. Does anyone know about what risks I'm into? Quoting him: [..] But indeed the weak point of C/C++ it is the security, and the Achilles' heel is indeed malloc and the abuse of pointers. C/C++ it is a...

some links for graphics in C

hello to everyone, I'm looking for some tutorials which can teach about graphics on C, I tryed find it, but all I can find are discussions about special topics, I'm beginner, thanks in advance ...

Use the keyword class as a variable name in C++

I am having trouble writing C++ code that uses a header file designed for a C file. In particular, the header file used a variable name called class: int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_class, BPY_class_attr_check* class_attrs, PyObject **py_class_attrs); This works in C as class isn't taken...

Problems with scanf

I'm having problems with this snippet of code: while(scanf("%d",&numOfPlayers)!=1){ printf("Please enter the right number of players"); } My purpose is to read a number from the user, and keep asking as long as the input isn't an int. When I run this snippet and input 'r' for example, I get stuck in an infinite loop...

Example applications and benefits of using C , C++ or Java

Ok, I'm revising for my upcoming year 2 exams on a CS course and its likely something like this will come up. my question is what is an ideal application that would especially benefit from the program features of each of the three languages? I have a vague idea but getting a second opinion could really help. JavaPortability, easy - good...

Problem linking SDL_Image against libpng

I'm trying to compile SDL_Image 1.2.10 with MinGW + MSys (gcc 4.5.0) on Windows, I have compiled all the requires libs (zlib 1.2.5, libpng 1.4.2, libjpeg 8a, libtiff 3.9.2). SDL_Image compiles fine, but fails to link to libpng, throwing .libs/IMG_png.o:IMG_png.c:(.text+0x16): undefined reference errors on various png structs. If I run ....

There was a function in C to adjust background color? (It was actually a Dos Command)

Hi, I am looking for the system function to adjust background color. It was like system("color",somecolorcodes); Does anyone know about it? On Windows Xp or 7! ...

Looping over all tabs in IE 8

Question: I want to loop over all open tabs in Internet Exporer (for all open IE windows) and save the URL in a text file. How can I do that ? I have windows 7 32 bit and IE 8. Code for Firefox/Google chrome would also be welcome. ...

sin v/s sinf fucntion in C

Hi Guys, I am trying to use sinf function in my C Program and it does give me undefined reference under MSVC 6.0 but sin works fine. This make me curious to find the difference between sin and sinf. What is the logical difference between sin and sinf(). How can I implement my own sinf functionality? ...

Why wont extern link to a static variable?

Why does extern int n not compile when n is declared (in a different file) static int n, but works when declared int n? (Both of these declarations were at file scope.) Basically, why is int n in file scope not the same as static int n in the same scope? Is it only in relation to extern? If so, what about extern am I missing? ...

Why aren't IOKit notifications being delivered with this code?

I wrote this code to subscribe to USB devices being plugged in and unplugged; the point is for IOKit to deliver notifications to my iAttached() and iDetached() functions when the corresponding events occur. However, I don't get notifications. The code can be seen here: http://gist.github.com/402391 I didn't want to over-populate this p...

gcc does not generate debugger info when using -g, -ggdb, -g3, or -ggdb3

I'm using GCC 4.4.1 and GDB 7.0-ubuntu on Ubuntu 9.10. However, GCC won't generate debugger info when using any of the following switches: -g, -g3, -ggdb, or -ggdb3. So when I run the program with GDB, its as if there was no debugger information generated. I have created very simple test source files in a new, empty folder. Here is one e...

C Programming: malloc() for a 2D array (using pointer-to-pointer)

Hi Guys, yesterday I had posted a question: How should I pass a pointer to a function and allocate memory for the passed pointer from inside the called function? From the answers I got, I was able to understand what mistake I was doing. I'm facing a new problem now, can anyone help out with this? I want to dynamically allocate a 2D ar...

How to learn to program C++ the right way

i have been programming in C/C++ for my academic courses a lot and was under the impression i had a pretty good grasp of it. but lately i had to work in a bluetooth application that had a server and client implementation in a Linux box and an embedded system. i learned bluez bluetooth API, socket/network programming and coded it. howev...