Im using C language for a PIC18F to produce tones such that each of them plays at certain time-interval. I used PWM to produce a tone. But I don't know how to create the intervals. Here is my attempt.
#pragma code //
void main (void)
{
int i=0;
// set internal oscillator to 1MHz
//OSCCON = 0b10110110; ...
In C I need to scale a uint8_t from 0 - 255 to 0 - 31
What is the best way to do this evenly?
...
So, I saw this:
error:(NSError **)error
in the apple doc's. Why two stars? What is the significance?
...
I have been writing C for only a scant few weeks and have not taken the time to worry myself too much about malloc(). Recently, though, a program of mine returned a string of happy faces instead of the true/false values I had expected to it.
If I create a struct like this:
typedef struct Cell {
struct Cell* subcells;
}
and then lat...
Here's a simple example of a program that concatenates two strings.
#include <stdio.h>
void strcat(char *s, char *t);
void strcat(char *s, char *t) {
while (*s++ != '\0');
s--;
while ((*s++ = *t++) != '\0');
}
int main() {
char *s = "hello";
strcat(s, " world");
while (*s != '\0') {
putchar(*s++);
...
What win32 API C functions can I use to read the modification/access/created dates of a file?
...
I was just reading the http://www.meebo.com/ About Us page, and read this line :
"plus, we're one of the few still around using C!"
Considering that meebo is an online chat client, how do they work with C? How can they use C for the backend? How does it interact with the frontend? For example, let's say a user creates a new account, and...
I have a situation in a code where there is a huge function that parses records line-by-line, validates and writes to another file.
In case there are errors in the file, it calls another function that rejects the record and writes the reject reason.
Due to a memory leak in the program, it crashes with SIGSEGV. One solution to kind of ...
In this question, someone suggested in a comment that I should not cast the results of malloc. I.e.
int *sieve = malloc(sizeof(int)*length);
rather than
int *sieve = (int *)malloc(sizeof(int)*length);
Why would this be the case?
...
The following function was written for java and has been adapted for C.
bool isFullwidthKatakana(WideChar C)
{
return(('\u30a0'<=C)&&(C<='\u30ff'));
}
The problem is that my framework ("CodeGear C++Builder") shows this error:
[BCC32 Warning] Unit1.cpp(101): W8114
Character represented by
universal-character-name '\u30a0'
...
Hi,
How can I pass a char * from C dll to VB
Here is sample code:
void Cfunc(char *buffer,int len)
{
BSTR buf_bstr = SysAllocString((BSTR)buffer);
VBptr.VBfunc(buf_bstr,len);
}
This function is not working, In actual some other values are sent to the VB rather than the actual value.
Can Anyone .. tell me how the solution for ...
Just trying to understand how to address a single character in an array of strings. Also, this of course will allow me to understand pointers to pointers subscripting in general.
If I have char **a and I want to reach the 3rd character of the 2nd string, does this work: **((a+1)+2)? Seems like it should...
...
/edit: thanks for the help so far, however I haven't got any of the solutions to take the sample input and give the sample output. My description isn't the clearest, sorry.
I have an array composed of binary data. What I want to do is determine how long each unbroken segment of 1s or 0s is.
Say I have this data:
0111010001110
In an ...
I have two threads, using C pthreads on linux. One of them writes data and the other is reading it. I'm using a variable to allow the read thread when is allowed to read and the write one when is allowed. So the mutex applies to this boolean variable called "newData". My question is: do I need to lock/unlock the mutex around the accesses...
I've change a c-style function to an objective-c method. As a method, how do i use it?
NSString* myfunc( int x )
is now:
- (NSString *)myFuncWithParam:(int)x
c code: myString = myfunc(x); // works
obj-c code: myString = myFuncWithParam(x); // fails to compile.
From one of the answers: myString = [object myF...
I've been using c-style functions, but I just learned they can't see instance variables. So I was advised to convert them to methods.
NSString* myfunc ( int x )
becomes:
- (NSString *)myfunc:(int)x
and
myString = myfunc(x);
becomes
myString = [myString myfunc: x];
??
This compiles with ominou...
I want to create something similar to a double linked list (but with arrays) that works with lower/upper bounds.
A typical circular array would probably look like:
next = (current + 1) % count;
previous = (current - 1) % count;
But what's the mathematical arithmetic to incorporate lower/upper bounds properly into this ?
0 (lower b...
I'm a bit new to working with c/c++, so sorry if this is a dumb question. I've been working on the Cell processor and I'm trying to create a struct that will hold an spe_context_ptr_t, which will be used within the thread to launch an spe context and will also hold a pointer to something else that will be passed to the spu context from w...
I'm trying to create an .lnk file programatically. I would prefer to use C, but C++ is fine (and is what all the MSDN stuff is in).
The relevant code sample is:
#include <windows.h>
#include <shobjidl.h>
#include <shlguid.h>
HRESULT CreateLink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszDesc) {
HRESULT hres;
IShellLink* p...
This example works fine:
static char *daytab[] = {
"hello",
"world"
};
This doesn't:
static char *daytab[] = {
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};
The way I see it is that the first example creates an array that is filled with pointers to the tw...