#include <string.h> #include <stdio.h> #define TOTAL_NUM 10 #define TOTAL_CHAR 30 #define TOTAL_BUF 256int main(void) { char allname[TOTAL_BUF] = "I am a student"; char name[TOTAL_NUM][TOTAL_CHAR] = {0}; char *pStr = NULL; char *pStep = " "; int nIdx = 0; printf("the string is: %s\n", allname); pStr = strtok(allname, pStep); if (NULL == pStr) { printf("no any string !\n"); return -1; } strcpy(name[nIdx++], pStr); while (pStr = strtok(NULL, pStep)) { if (nIdx < TOTAL_CHAR) { strcpy(name[nIdx++], pStr); } } printf("change postion string is: "); for (; nIdx-- > 0; ) { printf("%s ", name[nIdx]); } printf("\n"); return 0; }//代码已测试,楼主试试看
#include <string.h> #include <stdio.h> #define TOTAL_NUM 10 #define TOTAL_CHAR 30 #define TOTAL_BUF 256int main(void) { char allname[TOTAL_BUF] = "I am a student"; char name[TOTAL_NUM][TOTAL_CHAR] = {0}; char *pStr = NULL; char *pStep = " "; int nIdx = 0; printf("the string is: %s\n", allname); pStr = strtok(allname, pStep); if (NULL == pStr) { printf("no any string !\n"); return -1; } strcpy(name[nIdx++], pStr); while (pStr = strtok(NULL, pStep)) { if (nIdx < TOTAL_CHAR) { strcpy(name[nIdx++], pStr); } } printf("change postion string is: "); for (; nIdx-- > 0; ) { printf("%s ", name[nIdx]); } printf("\n"); return 0; }//代码已测试,楼主试试看
#include<stdio.h> void main() { char s[80]="I am a student"; int i,L; L = strlen(s); // 测字符串长度 for (i=0;i<L;i++){ printf("%c",s[L-i-1]); //倒着次序输出 } } //对不起看错题了,试试这个 有问题回我
#include <stdio.h> #define TOTAL_NUM 10
#define TOTAL_CHAR 30
#define TOTAL_BUF 256int main(void)
{
char allname[TOTAL_BUF] = "I am a student";
char name[TOTAL_NUM][TOTAL_CHAR] = {0};
char *pStr = NULL;
char *pStep = " ";
int nIdx = 0; printf("the string is: %s\n", allname);
pStr = strtok(allname, pStep);
if (NULL == pStr)
{
printf("no any string !\n");
return -1;
}
strcpy(name[nIdx++], pStr);
while (pStr = strtok(NULL, pStep))
{
if (nIdx < TOTAL_CHAR)
{
strcpy(name[nIdx++], pStr);
}
} printf("change postion string is: ");
for (; nIdx-- > 0; )
{
printf("%s ", name[nIdx]);
}
printf("\n"); return 0;
}//代码已测试,楼主试试看
#include <string.h>
#include <stdio.h> #define TOTAL_NUM 10
#define TOTAL_CHAR 30
#define TOTAL_BUF 256int main(void)
{
char allname[TOTAL_BUF] = "I am a student";
char name[TOTAL_NUM][TOTAL_CHAR] = {0};
char *pStr = NULL;
char *pStep = " ";
int nIdx = 0; printf("the string is: %s\n", allname);
pStr = strtok(allname, pStep);
if (NULL == pStr)
{
printf("no any string !\n");
return -1;
}
strcpy(name[nIdx++], pStr);
while (pStr = strtok(NULL, pStep))
{
if (nIdx < TOTAL_CHAR)
{
strcpy(name[nIdx++], pStr);
}
} printf("change postion string is: ");
for (; nIdx-- > 0; )
{
printf("%s ", name[nIdx]);
}
printf("\n"); return 0;
}//代码已测试,楼主试试看
#include<stdio.h>
void main()
{
char s[80]="I am a student";
int i,L;
L = strlen(s); // 测字符串长度
for (i=0;i<L;i++){
printf("%c",s[L-i-1]); //倒着次序输出
}
}
//对不起看错题了,试试这个 有问题回我