我正在学习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) 我有一组无符号长多数.我初始化前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) 我正在尝试将所有非字母数字字符过滤到字符串的末尾.我正在使用正则表达式很难,因为我不知道我们的特殊字符在哪里.这里有几个简单的例子.
hello*there*this*is*a*str*ing*with*asterisks
and&this&is&a&str&ing&&with&ersands&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)