char fn[256];
int rc;
pcm = calloc(1, sizeof(struct pcm));
if (!pcm || !config)
return &bad_pcm; /* TODO: could support default config here */
pcm->config = *config;
snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device,
flags & PCM_IN ? 'c' : 'p');
pcm->flags = flags;
pcm->fd = open(fn, O_RDWR);
if (pcm->fd < 0) {
oops(pcm, errno, "cannot open device '%s'", fn);
return pcm;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
// static
static int seq[] = {1,2,3,4,5,6};
static const char* string[] = { "a","b","c","d"};
static char* pstring= "http://www.ABCD.com";
/**
char fn[256];
snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device,
flags & PCM_IN ? 'c' : 'p');
**/
#define PCM_IN (0)
#define PCM_OUT (1)
int main()
{
int i = 0;
unsigned int card ;
unsigned int device;
unsigned int flags;
char fn[256] = {0};
sprintf(fn,"/dev/snd/pcmC%uD%u%c",card,device,flags & PCM_IN ? 'c' : 'p');
//printf("%s
",fn);
puts(fn);
snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device,
flags & PCM_IN ? 'c' : 'p');
puts(fn);
// strlen和sizeof的差距
printf("%d %d
",strlen(fn),sizeof(fn)/sizeof(char));
while(i++<strlen(fn))
{
puts(fn);
}
while(1);
return 0;
}