- (void)playAlarmSound:(NSTimer *)theTimer {
static SystemSoundID soundID/* = 0 */; // ?
if (!soundID) {
soundID = [Utilities createSystemSoundIDFromFile:@"beep" ofType:@"caf"];
}
...
}
Is SystemSoundID (which is a UInt32) automatically assigned 0? or should I explicitly assign it? I have to do it this way and t...
I have a basic C program that produces a number and the user has to guess it (yup, you've already called it: homework). I am able to get pretty much all of it so I am kinda proud, but I open to any errors I have made of course I am still learning. My main two questions are
How can I end this program early once the user has selected the...
We have a client/server communication system over UDP setup in windows. The problem we are facing is that when the throughput grows, packets are getting dropped. We suspect that this is due to the UDP receive buffer which is continuously being polled causing the buffer to be blocked and dropping any incoming packets. Is it possible th...
Guys,
I need to be able to (in C language) loop over a few lines of text where each line has some text in it where words are delimited by a variable number of white spaces. How can I detect the spaces and split each line into some kind of array so that I can put each word in a separate word tag in each line?
Any advice would be much ap...
I don't quite understand the point of having a header; it seems to violate the DRY principle! All the information in a header is (can be) contained in the implementation.
...
Is it possible to create a window that acts as an overlay on top of another window, say, an icon that you can display in the window's title bar or status bar?
Assume for the purposes of this question that:
The window is a foreign window (not owned by my application)
The overlay is 16x16 pixels and has a transparent background
The over...
How can I erase the current line printed on console in C ? I am working on a linux system
example -
printf("hello");
printf("bye");
I want to print bye on the same line in place of hello.
output
bye
...
Help appreciated. Couldn't find any mention of this in "the book" (k&r).
...
I have a comma separated string which might contain empty fields. For example:
1,2,,4
Using a basic
sscanf(string,"%[^,],%[^,],%[^,],%[^,],%[^,]", &val1, &val2, &val3, &val4);
I get all the values prior to the empty field, and unexpected results from the empty field onwards.
When I remove the expression for the empty field from th...
Trying to copy a char *str to char c[] but getting segmentation fault or invalid initializer error.
Why is this code is giving me a seg fault?
char *token = "some random string";
char c[80];
strcpy( c, token);
strncpy(c, token, sizeof c - 1);
c[79] = '\0';
char *broken = strtok(c, "#");
...
Possible Duplicate:
How to copy char *str to char c[] in C?
char *token = "some random string";
char c[80];
strncpy(c, token, sizeof c - 1);
c[79] = '\0';
char *broken = strtok(c, "#");
...
Does the shell allocates a job ID to all processes(foreground and background)?
jobs command shows the existing background jobs. How do we see job ID of foreground process?
I want to use a function in C (like getpid()) to get the job ID and status of a given process given the pid of the process.
What is the maximum value of a job ID?
...
char *token = "gkjsdhvcxvcvbcbcv"
char c[90];
strcpy( c, token);
c[sizeof(c)-1] = '\0';
char *broken = strtok(c, " ");
if ( broken != NULL)
{
//Should not come here as there is no white space???
}
...
If not, how can we start a background process in C?
...
I am trying to use strtok() in nested loop. But this is not giving me desired results.
Possibly because they are using same memory location. My code is of the form:-
char *token1 = strtok(Str1, "%");
while(token1 != NULL )
{
char *token2 = strtok(Str2, "%");
while(token2 != NULL )
{
//DO SMTHING
token2 = strtok(NULL, ...
Is there a way to fetch the system cpu load in windows xp via a DLL call or other means. I would like to embed the call in my program and when the CPU load hits 100% I would like to capture the time. My program is maxes out cpu load every couple of days, and I would like to figure out precisely when so I can do a data dump and analyze th...
I am reading K so far I'm doing well with it, but there is something in function itoa() which I don't understand. Here in itoa() they say they reverse the numbers themselves. For example 10 is 01 (they reverse the string):
void itoa(int n, char s[])
{
int i, sign;
if ((sign = n) < 0) /* record sign */
n = -n; /* make n p...
I want to reinitialize d everytime in a loop
char d[90];
while(ptr != NULL)
{
printf("Word: %s\n",ptr);
//int k = 0;
strcpy(d, ptr);
d[sizeof(d)-1] = '\0';
//something more
....
....
}
...
Half jokingly half serious: why can't I do ++i++ in C-like languages, specifically in C#?
I'd expect it to increment the value, use that in my expression, then increment again.
...
I have a Lisp reader written in Java that I'm thinking of translating into C. (Or perhaps C++.) It's a fairly complete and useful hack, so the main issue is doing the dynamic-storage allocation in a language without garbage collection. If someone has already thought this through I'd rather borrow their code than figure it out myself. ...