码迷,mamicode.com
首页 > 其他好文 > 详细

字符串加空格

时间:2015-04-13 18:05:52      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:

#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define N 100
void Insert(char s[]);
int main()
{
 char str[N];
 printf_s("input a string:");
 gets_s(str);
 Insert(str);
 printf_s("Insert results:%s\n",str);
 system("pause");
 return 0;
}
void Insert(char s[])
{
 char t[N];
 int i,j;
 strcpy_s(t,s);
 for(i = 0, j =0 ; t[i] != ‘\0‘;i++,j++)
 {
  s[j] = t[i];
  j++;
  s[j] = ‘ ‘;
 }
 s[j] = ‘\0‘;
}

字符串加空格

标签:

原文地址:http://www.cnblogs.com/joyclub/p/4422584.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!