c

C - only scalar operations?

Reading on Wikipedia: "The terms high-level and low-level are inherently relative. Some decades ago, the C language, and similar languages, was most often considered "high-level", as it supported concepts such as expression evaluation, parameterised recursive functions, and data types and structures, while assembly language was consi...

Basic skeleton for a C OpenGL program on OSX

What's the bare skeleton to get a triangle drawn on an OpenGL window in C on OSX? I've gone through the tutorials at Nehe and tried to get it working, but the CreateGLWindow seems hopelessly tied to win32. I want to stick to just opengl and glut, etc. I'll be eventually wrapping this in scheme, but I'd like to have a firmer understandin...

C to MIPS translation

Trying to convert this c code into MIPS and run it in SPIM. int A[100], B[100]; for(i=1; i<100; 1++){ A[i] = A[i-1] + B[i]; } So far this is what I have. # comments are delimted by has marks .data A: .word 0:100 # array of 12 integers B: .word 0:100 # array of 12 integers .text main: li $v0, 1 # l...

No error even when I'm overriding the limit of allocated memory?

I might be stupid and you need to excuse me in that case...but I don't get this. I'm allocating a buffer of 16 chars and then (in a for loop) put in 23(!?) random characters and then printing that stuff out. What I don't get is how I can put 23 chars into a buffer that is malloc'ed as 16 chars...When I change the loop to 24 characters I...

Various ways to get month name from inbuilt C library

What are the various ways to get the name of the month corresponding to an integer value [say 0 for Jan,1 for February ,...,11 for December] from inbuilt C/C++ library, I am familiar to strftime.Any other means to do the same ? ...

Source Insight: Show me Enum Values

I'm programming in C and using Source Insight. I have an enum type with a lot of constants (like 100). I have debug prints that print out variable values, but they (of course) print out as integers. What I'd like to do is click on the name of an enum constant, and see its numeric value displayed somewhere. (I've seen this done in a V...

Write a *.doc or *.rtf file from a c/c++ application

How can I write to/generate a *.doc file programmatically using c or c++? Is there a (open source/cross platform) library to do this? If this is not possible, can write an *.odt file and then convert it to *.doc? Thanks in advance! EDIT: Anders Abel commented that *.rtf file type is an option, so any suggestions on this one are also acc...

Problems calling MySQL stored procedures from C API

Hello, I have a problem calling a stored procedure on my MySQL server using the C API. I use mysql_query(&handle,"CALL myprocedure") but the function fails (returns 1) and error lookup gives the following message "Procedure myprocedure can't return a result set in the given context." I even tried to use mysql_real_query insted, but no ...

c program for the reverse the digits

I am looking for the c program for reverse the digits like ...... if i enter 123456 then the result would be .... 654321 plz any one help... ...

What have you used sysv/posix message queues for ?

I've never seen any project or anything utilizing posix or sysv message queues - and being curious, what problems or projects have you guys used them for ? ...

Does C support overloading ?

I just want to know if C supports over loading? As we use system functions like printf with different no of arguments. Help me out ...

Why does PortAudio not play nicely with other audio programs or how can I get it to?

I am trying to write an audio application using PortAudio, but if any other audio programs (usually Firefox) are running at the time which I try to run my program, I get the following error: PaHost_OpenStream: could not open /dev/dsp for O_WRONLY PaHost_OpenStream: ERROR - result = -10000 An error occured while using the portaudio strea...

Display web page using libgtkhtml c c++

I want to display a very simple html page from the web, using libgtkhtml. Can you give an example please? Or some documentation/resources? I found nothing. (C preferred, but C++ also acceptable). Thanks in advance. ...

Max identifier length

Where can I find what is the maximum identifier length in C? In which header file is that limit specified? ...

in C: Why does a stack allocated structure exist outside of the function?

my function: struct hostent * gethost(char * hostname){ if(/*some condition under which I want to change the mode of my program to not take a host*/){ return null } else{ struct hostent * host = gethostbyname(hostname); return host; } } in main: struct hostent * host = gethost(argv[2])...

getpwnam on Ubuntu behaves differently if compiled in 32-bit

I'm setting up a ZABBIX agent (written in C) on a couple of Ubuntu 64-bit servers. I usually compile everything in 32-bit unless I specifically need 64-bit (such as database servers.) The servers in question will be hosting virtual servers and have 8GB RAM, hence why I've kept them 64-bit. If the ZABBIX agent starts as root, it tries ...

C as an object oriented language

Could you suggest a syntax for the C language to use it in a similar way than an object-oriented language? I know that they cannot be the same and that some keywords aren't present in C, but I'm wondering if there is a way to take advantage of certain aspects (like inheritance) even in a C program. ...

Using JSON data

Hi. I am trying to make a simple twitter client in C. I'm new at this and not sure how to go about segregating meaningful stuff from the JSON string that I get from the API. For example, if I get this as a response from the API, how do I extract out the value of "text" into a string (char*)? I guess I can work with the string at low ...

Interacting with a remote server over network

I need to connect to a remote server whose remote name and PORT number is specified to me. This I need to do over Unix sockets. After connecting with it, I will need to receive the messages the server sends and then send it data as it instructs me to do. I know the steps to make this client program but i'm lost as to the exact things I n...

How to ensure a dynamically allocated array is private in openmp

I'm working in C with openMP using gcc on a linux machine. In an openmp parallel for loop, I can declare a statically allocated array as private. Consider the code fragment: int a[10]; #pragma omp parallel for shared(none) firstprivate(a) for(i=0;i<4;i++){ And everything works as expected. But if instead I allocate a dynamically, i...