Ejemplo n.º 1
0
void trans_space(char *str, char word, const char *slace)
{
    if(slace == NULL || str == NULL)
    {
        return;
    }

    int length = m_strlen(str);
    int slace_length = m_strlen(slace);
    int i = 0;
    int j = 0;

    char tp[MAX_STR_LEN] = { 0 };

    for(i = 0; i < length; ++i){
        if(str[i] == word){
            m_strcat(tp, slace);
            j += m_strlen(slace);
        }else{
            tp[j] = str[i];
            j += 1;
        }
    }
    m_strcpy(str, tp);
}
Ejemplo n.º 2
0
char    *m_strcat(char *string1, char *string2)
{
  int   len1 = m_strlen(string1, "");
  int   len2 = m_strlen(string2, "");
  char  *ptr = m_malloc(len1 + len2 + 1);

  if (ptr == NULL)
    return (NULL);
  m_strncpy(ptr, string1, len1);
  m_strncpy(&ptr[len1], string2, len2);
  ptr[len1 + len2] = 0;
  return (ptr);
}
Ejemplo n.º 3
0
char *m_strcat(char *dst, const char *src)
{
    if(dst == NULL || src == NULL){
        return NULL;
    }

    int len_d = m_strlen(dst);
    int len_s = m_strlen(src);
    int i = len_d;
    int j = 0;

    for(j = 0; j <= len_s; ++j, ++i){
        dst[i] = src[j];
    }
    return dst;
}
Ejemplo n.º 4
0
void NameServer_SetName(NameServer * ns, int tid, char * name) {
	if (0 <= tid && tid < MAX_TASKS + 1) {
		m_strcpy(ns->names[tid], name, m_strlen(name) + 1);
		ns->filled[tid] = 1;
	} else {
		assert(0,"Out of space for registered names in name server.");
	}
}
Ejemplo n.º 5
0
void NameServer_SetName(NameServer * ns, int tid, char * name) {
	assertf(m_strlen(name) <= MAX_CLIENT_NAME_LENGTH, "NameServer: name '%s' too long", name);

	if (0 <= tid && tid < MAX_TASKS + 1) {
		m_strcpy(ns->names[tid], name, CLIENT_NAME_SIZE);
		ns->filled[tid] = 1;
	} else {
		assert(0,"Out of space for registered names in name server.");
	}
}
Ejemplo n.º 6
0
int foo (char *a, int len) {
    if (len < 0) {
        len = m_strlen(a);
    }
    int sum = 0;
    for (int i = 0; i < len; i++) {
        sum += (int)a[i];
    }
    return sum;
}
Ejemplo n.º 7
0
Archivo: strcmp.c Proyecto: tectrendz/p
void myrevstr(char * str)
{
    int len = m_strlen(str);
    char ch;
    int mid = (len-1)/2;
    for (int i = 0; i < mid; i++) {
        ch = str[len-1-i];
	str[len-1-i]  = str[i];
        str[i] = ch; 
    }
}    
Ejemplo n.º 8
0
Archivo: strcmp.c Proyecto: tectrendz/p
void myrevstr1(char * str)
{
    int len = m_strlen(str);
    char ch;
    char *end = str+len - 1;
    int mid = (len-1)/2;
    for (int i = 0; i < mid; i++) {
        ch = *end;
	*end-- = *str;
        *str++ = ch; 
    }
}    
Ejemplo n.º 9
0
void EncoderSwitchPage::display() {
  if (redisplay) {
    GUI.setLine(GUI.LINE1);
    GUI.clearLine();
    if (pages[0] != NULL) {
      GUI.put_string_at(0, pages[0]->name);
    }
    if (pages[3] != NULL) {
      int l = m_strlen(pages[3]->name);
      GUI.put_string_at(15 - l, pages[3]->name);
    }

    GUI.setLine(GUI.LINE2);
    GUI.clearLine();
    if (pages[1] != NULL) {
      GUI.put_string_at(0, pages[1]->name);
    }
    if (pages[2] != NULL) {
      int l = m_strlen(pages[2]->name);
      GUI.put_string_at(15 - l, pages[2]->name);
    }
  }
}
Ejemplo n.º 10
0
void deal_space(char *str, char word, const char *slace)
{
    int str_length = m_strlen(str);
    int slace_length = m_strlen(slace);
    int space_num = 0;
    int total_length = 0;
    int i = 0;

    // how many sapces
    for(i = 0; i < str_length; ++i){
        if(str[i] == word){
            space_num += 1;
        }
    }
    total_length = str_length + (slace_length - 1) * space_num;
    printf("total length %d\n", total_length);

    for( ; str_length >= 0; ){
        if(str[str_length] == word){
            int flag = 2;
            while(flag--){
                str[--total_length] = '^';
            }
            --str_length;

        }else{
            str[total_length] = str[str_length];
            str[str_length] = ' ';

            --str_length;
            --total_length;
        }


        printf("%s\n", str);
    }
}
Ejemplo n.º 11
0
/* ****************************** Main ****************************** */
int main(int argc, char *argv[])
{
	char garbage[] = "Pointers and integers are not interchangeable. Zero is the sole exception: the constant zeromay be assigned to apointer, and a pointer may be compared with the constant zero. Thesymbolic constant NULL is";
	char *p;

	p = alloc(m_strlen(garbage));
	m_strset(garbage, p);
	printf("%d\n%s\n",(int)(allocp - allocbuf) , p);
	afree(p);
	printf("%d\n%s\n",(int)(allocp - allocbuf) , p);

	p = alloc(10);
	m_strset("0123456789",p);
	printf("%d\n%s\n",(int)(allocp - allocbuf) , allocbuf);

	return 0;
}
Ejemplo n.º 12
0
String::String(const char *src) : size(m_strlen(src))
{
	str = new char[size + 1];
	m_strcpy(str, src);
}
Ejemplo n.º 13
0
void    m_strcpy(char *dest, char *src)
{
  m_strncpy(dest, src, m_strlen(src, ""));
}