void * scoresDescendingSort(struct student *students, int len) {
	int i,j;struct student temp;
	if(students==NULL||len<=0)
        return NULL;
    else
    {
        for(i=0;i<len;i++)
        {
            for(j=0;j<len-i-1;j++)
            {
                if(students[j].score<students[j+1].score)
                {
                    mystrcpy(temp.name,students[j].name);
                    //while(*(temp.name)++=*(students[j].name)++);
                    temp.score =students[j].score;
                    //student[j].name=(char*)malloc(sizeof(student[j+1].name)+1)
                    mystrcpy((students[j].name),(students[j+1].name));
                    students[j].score= students[j+1].score;
                    mystrcpy(students[j+1].name ,temp.name);
                    students[j+1].score = temp.score;
                }
            }
        }
    }

}
Exemplo n.º 2
0
EventLog::EventLog(const EventLog& other)
{
  mystrcpy(this->name, other.name);
  mystrcpy(this->eventList, other.eventList);
  this->lastIndex = other.lastIndex;
  this->listCapacity = other.listCapacity;
}
Exemplo n.º 3
0
Arquivo: sol.c Projeto: shhdup/msu-cs
void insert(struct node *root, unsigned char *s) {
    if (!*s) return;
    unsigned char fc = *s;
    if (!root->go[fc]) {
        root->go[fc] = mk_node();
        mystrcpy(&root->edge[fc], s);
        return;
    }
    unsigned char *foo = s;
    while (*foo && root->edge[fc][foo-s] == *foo) {
        ++foo;
    }
    if (!*foo) return;
    if (root->edge[fc][foo-s]) {
        struct node *bar = mk_node();
        struct node *baz = mk_node();
        bar->go[*foo] = baz;
        mystrcpy(&bar->edge[*foo], foo);
        bar->go[root->edge[fc][foo-s]] = root->go[fc];
        mystrcpy(&bar->edge[root->edge[fc][foo-s]], root->edge[fc]+(foo-s));
        int newlen = foo-s;
        root->edge[fc] = (unsigned char *) realloc(root->edge[fc], (newlen+1)*sizeof(unsigned char));
        root->edge[fc][newlen] = 0;
        root->go[fc] = bar;
    } else {
        insert(root->go[fc], foo);
    }
}
Exemplo n.º 4
0
long LogOpenQuiet( char *filename, __int64 *filelen )
{
	char	rawfileName[256];
	long	hnd = 0;

	DateFixFilename( filename, rawfileName );

	// Check if we trying to open a shortcut
	if ( IsShortCut( rawfileName ) ){
		char linkpath[256];
		mystrcpy( linkpath, rawfileName );
#if DEF_WINDOWS
		GetShortCut( linkpath, rawfileName );
#endif
	}

	// Now see if the we want to open a short cut to a URL
	if ( IsURLShortCut( rawfileName ) ){
		char linkpath[256];
		mystrcpy( linkpath, rawfileName );
#if DEF_WINDOWS
		GetURLShortCut( linkpath, rawfileName );
#endif
	}

	// Check for a just a plain URL
	if ( IsURL( rawfileName ) ){
		StatusSetID( IDS_REMOTELOG , strrchr( rawfileName,'/' ) );
		hnd = (long)INetOpen( rawfileName, filelen );
		return hnd;
	}

	// Check other types
	char format[100];
	// determine if its PKZIP file and if so... dont open it, YET
	if ( IsFileInvalid( rawfileName, format ) )
		return 0;

#ifndef DEF_MAC
	if ( IsPKZIP( rawfileName ) )
		hnd = (long)UnzipOpen( rawfileName, NULL );
	else
#ifdef _BZLIB_H
	if ( aIsBzFile( rawfileName ) )		// PLEASE DO THIS SOON FOR MAC.... at least for manual completeness, hey OSX people will love it.
		hnd = (long)BZ2_bzopen( rawfileName, "rb" );
	else 
#endif
#endif
	{
		hnd = (long)gzopen( rawfileName, "rb" );
	}

	if ( filelen && hnd )
		*filelen = GetFileLength( rawfileName );

	return hnd;
}
Exemplo n.º 5
0
void test2() {
	char a[200];
	char * b;
	b = mystrcpy(a, "Hello world");
	printf("\"%s\"\n", a);
	printf("\"%s\"\n", b);

	b = mystrcpy(a, "");
	printf("\"%s\"\n", a);
	printf("\"%s\"\n", b);
}
Exemplo n.º 6
0
Phone::Phone()
{
  mystrcpy(this->brand, "UnknownBrand");
  mystrcpy(this->model, "UnknownModel");
  this->totalMemory = DEFAULT_MEMORY;
  this->freeMemory = DEFAULT_MEMORY;
  this->isTouchScreen = false;
  this->screenSize = DEFAULT_SCREENSIZE;
  this->weight = DEFAULT_WEIGHT;
  this->hoursBatteryLasts = DEFAULT_BATTERYLAST;
  this->currentBattery = DEFAULT_BATTERY;
}
Exemplo n.º 7
0
Phone::Phone(const Phone& other)
{
  mystrcpy(this->brand, other.brand);
  mystrcpy(this->model, other.model);
  this->totalMemory = other.totalMemory;
  this->freeMemory = other.freeMemory;
  this->isTouchScreen = other.isTouchScreen;
  this->screenSize = other.screenSize;
  this->weight = other.weight;
  this->hoursBatteryLasts = other.hoursBatteryLasts;
  this->currentBattery = other.currentBattery;
}
Exemplo n.º 8
0
Phone::Phone(char* brand, char* model, int totalMemory, int freeMemory, bool isTouchScreen, double screenSize, double weight, double hoursBatteryLasts, int currentBattery)
{
  mystrcpy(this->brand, brand);
  mystrcpy(this->model, model);
  this->totalMemory = totalMemory;
  this->freeMemory = freeMemory;
  this->isTouchScreen = isTouchScreen;
  this->screenSize = screenSize;
  this->weight = weight;
  this->hoursBatteryLasts = hoursBatteryLasts;
  this->currentBattery = currentBattery;
}
Exemplo n.º 9
0
Arquivo: image.c Projeto: jobovy/nemo
int sub_image (imageptr iptr, regionptr rptr, imageptr *optr)
{
  int nx,ny,nz, nx1,ny1,nz1, ix,iy,iz, ix0,iy0,iz0;
  size_t np, np1;

  nx  = Nx(iptr);
  ny  = Ny(iptr);
  nz  = Nz(iptr);
  np = nx*ny*nz;
  /* grab the bounding box */
  ix0 = BLC(rptr)[0];
  iy0 = BLC(rptr)[1];
  iz0 = BLC(rptr)[2];
  nx1 = TRC(rptr)[0] - ix0;
  ny1 = TRC(rptr)[1] - iy0;
  nz1 = TRC(rptr)[2] - iz0;
  np1 = nx1*ny1*nz1;

  *optr = (imageptr ) allocate(sizeof(image));
  dprintf (DLEV,"copy_image:Allocated image @ %d size=%d * %d * %d",*optr,nx1,ny1,nz1);
    	
  Frame(*optr) = (real *) allocate(np1*sizeof(real));	
  dprintf (DLEV,"Frame allocated @ %d ",Frame(*optr));
  Nx(*optr) = nx1;
  Ny(*optr) = ny1;
  Nz(*optr) = nz1;
  Xmin(*optr) = Xmin(iptr) + ix0*Dx(iptr);
  Ymin(*optr) = Ymin(iptr) + iy0*Dy(iptr);
  Zmin(*optr) = Zmin(iptr) + iz0*Dz(iptr);
  Dx(*optr) = Dx(iptr);
  Dy(*optr) = Dy(iptr);
  Dz(*optr) = Dz(iptr);
  Namex(*optr) = mystrcpy(Namex(iptr));
  Namey(*optr) = mystrcpy(Namey(iptr));
  Namez(*optr) = mystrcpy(Namez(iptr));
  Xref(*optr) = Xref(iptr) + ix0;
  Yref(*optr) = Yref(iptr) + iy0;
  Zref(*optr) = Zref(iptr) + iz0;
  for (iz=0; iz<nz1; iz++)
    for (iy=0; iy<ny1; iy++)
      for (ix=0; ix<nx1; ix++)
	CubeValue(*optr,ix,iy,iz) = CubeValue(iptr,ix-ix0,iy-iy0,iz-iy0);
  Storage(*optr) = matdef[idef];
  Axis(*optr) = Axis(iptr);
  set_iarray(*optr);
  
  return 1;		/* succes return code  */
}
Exemplo n.º 10
0
Arquivo: Ui.c Projeto: kichik/nsis-1
static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  static LPARAM last_item=-1;
  if (uMsg == WM_CHAR && wParam == (WPARAM)' ')
  {
    NotifyCurWnd(WM_TREEVIEW_KEYHACK);
    return 0;
  }
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)
  if (uMsg == WM_DESTROY) {
    last_item=-1;
  }
  if (uMsg == WM_MOUSEMOVE) {
    TVITEM tvItem;

    if (IsWindowVisible(hwnd)) {
      tvItem.hItem = TreeHitTest(hwnd);

      lParam = -1;

      if (tvItem.hItem)
      {
        tvItem.mask = TVIF_PARAM;

        TreeView_GetItem(hwnd, &tvItem);

        lParam = tvItem.lParam;
      }
      uMsg = WM_NOTIFY_SELCHANGE;
    }
  }
  if (uMsg == WM_NOTIFY_SELCHANGE) {
    if (last_item != lParam)
    {
      last_item = lParam;

      mystrcpy(g_tmp, g_usrvars[0]);

      myitoa(g_usrvars[0], lParam);

      ExecuteCodeSegment(g_header->code_onMouseOverSection,NULL);

      mystrcpy(g_usrvars[0], g_tmp);
    }
  }
#endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_ENHANCEDUI_SUPPORT
  return CallWindowProc((WNDPROC)oldTreeWndProc,hwnd,uMsg,wParam,lParam);
}
Exemplo n.º 11
0
/*
 * The following are simple tests to help you.
 * You should develop more extensive tests to try and find bugs.
 */
int main()
{
	const int SIZE = 100;
	char buffer[SIZE];

	assert(mystrlen("cmpt 300") == 8);
	assert(mystrlen("") == 0);

	assert(mystrcmp("adam", "") == 1);
	assert(mystrcmp("", "adam") == -1);
	mystrcpy(buffer, "adam");
	assert(mystrcmp(buffer, "adam") == 0);
	assert(mystrcmp(buffer, "adampie") == -1);
	assert(mystrcmp("applepie", "apple") == 1);
	assert(mystrcmp("", "") == 0);
	assert(mystrcmp(buffer, "ADAM") != 0);
	assert(mystrcmp ("I love coding", "I love coding") == 0);

	char *dupStr = mystrdup(buffer);
	assert (!mystrcmp(buffer, dupStr));
	assert (buffer != dupStr);

	if (dupStr != NULL)
		free (dupStr);

	printf ("\nPassed VERY simple tests, remember to develop more tests.\n");

	return 0;
}
Exemplo n.º 12
0
EventLog::EventLog(const char* name)
{
  mystrcpy(this->name, name);
  eventList = new char[DEFAULT_CAP];
  lastIndex = 0;
  listCapacity = DEFAULT_CAP;
}
Exemplo n.º 13
0
void test3() {
	char a[200];
	char * b;
	mystrcpy(a, "Hello world");
	b = mystrcat(a, ", CS240 C Programming");
	b = mystrcat(a, ", This is a great course");
	printf("\"%s\"\n", a);
	printf("\"%s\"\n", b);

	mystrcpy(a, "");
	b = mystrcat(a, "");
	b = mystrcat(b, "Hello");
	
	printf("\"%s\"\n", a);
	printf("\"%s\"\n", b);
}
Exemplo n.º 14
0
int main(void)
{
	char s1[LIMIT];
	char s2[LIMIT];
	int n;

	printf("Enter a string to copy: ");
	get(s2, LIMIT);
	while (s2[0] != '\0')
	{
		printf("How many characters do you want to copy? (maximum %d) ", LIMIT);
		scanf("%d", &n);

		while (getchar() != '\n')
			continue;

		if (n > LIMIT)
			n = LIMIT;

		printf("Original string: %s\n", s2);
		mystrcpy(s1, s2, n);
		printf("Copy: %s\n", s1);

		clear_string(s1, LIMIT);

		printf("Enter a string to copy (empty line to quit): ");
		get(s2, LIMIT);
	}

	puts("Bye");

	return 0;
}
Exemplo n.º 15
0
static int changeFormat(char *const format_dest, char const *const format_src, size_t const format_len)
{
    size_t i=0;
    int iPercent=0;

    mystrcpy(format_dest,format_src,format_len);
    /*on remplace les %z par des %l dans les chaines de format version C89*/
    /*for(i=0;i<format_len-1;i++)
    {
        if ((format_dest[i]=='%')&&(format_dest[i+1]=='z'))
        {
            format_dest[i+1]='l';
        }
    }*/

    i=0;
    while(i<format_len-1)
    {
        if (format_dest[i]=='%')
            iPercent=1;
        if ((format_dest[i]=='z')&&(iPercent==1))
        {
            iPercent=0;
            format_dest[i]='l';
        }
        if ((format_dest[i]>='a')&&(format_dest[i]<'z')&&(iPercent==1))
        {
            iPercent=0;
        }
        i++;

    }

    return 0;
}
Exemplo n.º 16
0
bool CTalkName::Add(bool _left, int _num, ...){

	if (_num>0){
		va_list args;
		va_start(args, _num);	//_numが大きすぎたときの処置方法はないのか?

		int side = (_left? 0: 1);
		NowLeft = _left;

		for (int h=0; h<_num; h++){
			char* tmp = va_arg(args, char*);
			
			for (int i=0; i<NAME_NUM; i++){	
				if (mystrcmp(Name[side][i], tmp)){
					break;
				}else if (Name[side][i][0]=='\0'){
					mystrcpy(Name[side][i], tmp, 32);
					break;
				}else if (i==NAME_NUM-1){
					ErrorDx("Error->CTalkName::Add->Too many names :%s", __FILE__, __LINE__, tmp);
					va_end(args);
					return false;
				}				
			}
		}
		va_end(args);
		return true;

	}else{
Exemplo n.º 17
0
//session 1
int main(int argc, char*argv[])
{

	for(int i=0;i<argc;i++)
	{	
	//Check my name in the argument
		if(mystrcmp("Chen",argv[i])==0)
		{	
			//copy"Hello" to the array 
			char hi[30];
			mystrcpy(hi,"Hello, ");
			//put my name after hello
			mystrcat(hi,argv[i]);
			printf("%s\n",hi);
		}
		else{
			printf("%s\n",argv[i]);
		}
	}
	

//session 6
	int a[10];
	
	for(int i=0; i<10;i++)
	{
		a[i]=i*i;
		printf("%d\n", *(a+i));
	}
		
}
int main ()
{
	char str[40];
	printf("%s",mystrcpy(str,"學c真辛苦"));
	
	//函數返回指針的地址,不成功返回NULL,成功返回地址 
}
Exemplo n.º 19
0
int main(int argc, char **argv)
{
	char t[100];
	mystrcpy(t, argv[1]);
	printf("%s\n", t);
	return 0;
}
Exemplo n.º 20
0
void addNode(BinSTreeNode *rootNode, BinSTreeNode *node) {
  if (node == NULL) {
    return;
  }
  if (rootNode->str == NULL) { /* rootNode is empty! */
    rootNode->str = (char*)malloc(sizeof(char)*(mystrlen(node->str)+1));
    mystrcpy(rootNode->str, node->str);
    setNodeAsLeft(rootNode, node->left);
    setNodeAsRight(rootNode, node->right);
    node->left = NULL;
    node->right = NULL;
    deleteNode(node);
  } else {  /* Normal addNode() */
    if (isLeft(rootNode, node)) {   /* node should be left of root */
      if (rootNode->left == NULL) { /* There is no left child */
        setNodeAsLeft(rootNode, node);
        if(DEBUG) printf("Add  %s  <- [%s%s%s]\n", node->str, CYAN, rootNode->str, DEFAULT);
      } else {  /* search for left edge */
        addNode(rootNode->left, node);
      }
    } else {    /* root <= node */
      if (rootNode->right == NULL) { /* There is no right child */
        setNodeAsRight(rootNode, node);
        if(DEBUG) printf("Add [%s%s%s] ->  %s\n", CYAN, rootNode->str, DEFAULT, node->str);
      } else {  /* search for left edge */
        addNode(rootNode->right, node);
      }
    }
  }
  return;
}
Exemplo n.º 21
0
int main(){
	char s[30] = "hello";
	char * s1 = ",world";
	printf("%s\n",mystrcpy(s,s1));
	printf("%s\n",strcpy(s,s1));
	return 0;
}
Exemplo n.º 22
0
int main()
{
t=arr1;
s=arr2;

printf("copiamos un string t= a otro s\n");
printf("mostramos que contienen los strings\n");
printf("primero el string origen=");
int i=0;

while(arr1[i])
 printf("%c",arr1[i++]);
printf("\n\n");
i=0;
printf("luego  el string destino=");
while(arr2[i])
 printf("%c",arr2[i++]);
printf("\n\n");


mystrcpy(s,t);

printf("mostramos como queda el destino=");
i=0;
while(arr2[i])
 printf("%c",arr2[i++]);
printf("\n\n");

} 
Exemplo n.º 23
0
Arquivo: Ui.c Projeto: kichik/nsis-1
static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  static LPARAM last_item=-1;
  if (uMsg == WM_KEYDOWN && wParam == VK_SPACE)
  {
    SendMessage(m_curwnd,WM_TREEVIEW_KEYHACK,0,0);
  }
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)
  if (uMsg == WM_DESTROY) {
    last_item=-1;
  }
  if (uMsg == WM_MOUSEMOVE) {
    TVITEM tvItem;

    if (GetWindowLong(hwnd, GWL_STYLE) & WS_VISIBLE) {
      tvItem.hItem = TreeHitTest(hwnd);
      
      lParam = -1;

      if (tvItem.hItem)
      {
        tvItem.mask = TVIF_PARAM;

        TreeView_GetItem(hwnd, &tvItem);
        
        lParam = tvItem.lParam;
      }
      uMsg = WM_NOTIFY_SELCHANGE;
    }
  }
  if (uMsg == WM_NOTIFY_SELCHANGE) {
    if (last_item != lParam)
    {
      last_item = lParam;

      mystrcpy(g_tmp, g_usrvars[0]);

      myitoa(g_usrvars[0], lParam);

      ExecuteCodeSegment(g_header->code_onMouseOverSection,NULL);

      mystrcpy(g_usrvars[0], g_tmp);
    }
  }
#endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_ENHANCEDUI_SUPPORT
  return CallWindowProc((WNDPROC)oldTreeWndProc,hwnd,uMsg,wParam,lParam);
}
Exemplo n.º 24
0
void main( )
{
char  *a = "I am a teacher.";
char b[] = "You are a student.";
printf("a = %s, b=%s\n",a,b);
mystrcpy(a,b);
printf("a = %s, b=%s\n",a,b);
}
Exemplo n.º 25
0
int main(){
	char* source = "abc";
	char* destination=malloc((strlen(source)+1)*sizeof(char));
	destination=mystrcpy(destination,source);

	printf("%d \n",myStrlen(destination));
	printf("%s \n",myStrdup(source));
}
Exemplo n.º 26
0
char * mystrdup(char * s) {

	char *d = malloc (mystrlen (s) + 1);
	if (d == NULL) return NULL;

	mystrcpy(d, s);
	return d;
}
Exemplo n.º 27
0
Arquivo: 2.c Projeto: rafed123/codes
void main(){

    char str[80];

    mystrcpy(str,"this is a test");
    printf(str);

}
int main()
{
	char dest[1024];
	char src[] = "abcdef";
	mystrcpy(dest, src);
	printf("%s\n", dest);
	return 0;
}
Exemplo n.º 29
0
EventLog& EventLog::operator=(const EventLog& other)
{
  if(this != &other)
  {
    if(this->name)
      delete[] this->name;

    if(this->eventList)
      delete[] this->eventList;

    mystrcpy(this->name, other.name);
    mystrcpy(this->eventList, other.eventList);
    this->lastIndex = other.lastIndex;
    this->listCapacity = other.listCapacity;
  }
  return *this;
}
Exemplo n.º 30
0
int main()
{
	char source[] = "This is the source string";
    char destination[50];
    printf("%s",mystrcpy(destination,source));
    char *combined=concatw(source,destination);
    printf("%s",combined);
}