小编use*_*058的帖子

如何通过C中的指针传递2D数组?

我正在学习C并且无法将2D数组的指针传递给另一个函数然后打印2D数组.任何帮助,将不胜感激.

int main( void ){
    char array[50][50];
    int SIZE;

    ...call function to fill array... this part works.

    printarray( array, SIZE );
}

void printarray( char **array, int SIZE ){
    int i;
    int j;

    for( j = 0; j < SIZE; j++ ){
        for( i = 0; i < SIZE; i ++){
            printf( "%c ", array[j][i] );
        }
        printf( "\n" );
    }
}
Run Code Online (Sandbox Code Playgroud)

c arrays pointers

33
推荐指数
3
解决办法
6万
查看次数

查找动态分配的无符号long long数组的长度

我有一组无符号长多数.我初始化前12个元素.该数组在整个程序运行时更改大小.我怎样才能找出数组的长度.

我不能使用sizeof(array)/ sizeof(unsigned long long),因为在这种情况下它无法正常工作.

我尝试使用这个循环:

count = 0;
while ( array[count] ) count++;
return count;
Run Code Online (Sandbox Code Playgroud)

这种方法的问题是它仍然返回错误的长度.

这是代码的基本概要.

unsigned long long *prime = (unsigned long long *)calloc(1000, sizeof(unsigned long long);
prime[0] = 3;
prime[1] = 5;
....
prime[11] = 41;
unsigned long long *ptrEmpty = &prime[12];
int sizeComp;

//User can change change the size of the array here to create a larger list of primes.//
for( i = 43, sizeComp = 12; sizeComp < length(prime); i += 2 ){
    // …
Run Code Online (Sandbox Code Playgroud)

c arrays

1
推荐指数
1
解决办法
896
查看次数

如何在Python中将所有特殊字符移动到字符串的末尾?

我正在尝试将所有非字母数字字符过滤到字符串的末尾.我正在使用正则表达式很难,因为我不知道我们的特殊字符在哪里.这里有几个简单的例子.

hello*there*this*is*a*str*ing*with*asterisks
and&this&is&a&str&ing&&with&ampersands&in&i&t
one%mo%refor%good%mea%sure%I%think%you%get%it
Run Code Online (Sandbox Code Playgroud)

我如何将所有特殊字符滑动到字符串的末尾?

这是我尝试过的,但我没有得到任何东西.

re.compile(r'(.+?)(\**)')
r.sub(r'\1\2', string)
Run Code Online (Sandbox Code Playgroud)

编辑:

第一个字符串的预期输出将是:

hellotherethisisastringwithasterisks********
Run Code Online (Sandbox Code Playgroud)

python regex

0
推荐指数
1
解决办法
364
查看次数

标签 统计

arrays ×2

c ×2

pointers ×1

python ×1

regex ×1