C程序出现个问题,求解答(字符串赋值出现异常)
#include <stdio.h>
#include <string.h>
#define m0 30
typedef struct
{
char vec[m0];
int len;
} orderstring;
void maxcomstr(orderstring *s,orderstring *t)
{
int index = 0, length = 0, i, j, k, length1;
i = 0;
while (i <s->len)
{
j = 0;
while (j < t->len)
{
if(s->vec[i] == t->vec[j])
{
length1 = 1;
for(k = 1; s->vec[i+k] == t->vec[j+k] && s->vec[i+k] != NULL ; k++)
{
length1 = length1 + 1;
}
if(length1 > length)
{
index = i;
length = length1;
}
j+= length1;
}
else
{
j++;
}
}
i++;
}
printf("最长公共子串:");
for (i = 0; i < length; i++)
{
printf("%c",s->vec[index + 1]);
}
}
void main()
{
orderstring *r,*r1;
r->len = 11;
strcpy(r->vec,"aabcdababce"); //这个地方出现异常,请问如何给这个赋值
r1->len = 12;
strcpy(r1->vec,"12abcabcdace");
maxcomstr(r,r1);
}
你的指针没有分配内存
warning C4700: local variable 'r' used without ha
相关问答:
在查询后将查询出来的值赋给各输入框
<c:if test="${not empty dataValue}">
fm.SAMPLING_DATE.value=" <c:out value='${dataValue.SAMPLING_DATE}'/ ......
编译普通的c没问题啊,但编译javah生成的就报错:
gcc -O0 -g3 -Wall -c -fmessage-length=0 -oHelloWorld.o ..\HelloWorld.c
gcc -otest.exe HelloWorld.o
d:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../. ......
如题,求教各位大侠!!多谢
自己顶上~~
longlong
long long
呃~~如果遇到long long都没办法的时候呢?
而且有long long这样的类型?我只记得有long double呵
用数组存,或者自己整个数据结构。
......
用dev-c++编译的
是c primer plus 的例题
程序如下:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
unsigned int un = 3000000000; /* 32位int ......