Skip to content

Instantly share code, notes, and snippets.

@ionutale
Last active June 10, 2020 05:26
Show Gist options
  • Save ionutale/7471ad97f84eead8bdf7a67c2c412abd to your computer and use it in GitHub Desktop.
Save ionutale/7471ad97f84eead8bdf7a67c2c412abd to your computer and use it in GitHub Desktop.
the test that cosmin had
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
int main()
{
char s1[30] = "";
char s2[30] = "";
scanf("%s", s1);
scanf("%s", s2);
int s1Len = getLength(s1);
int s2Len = getLength(s2);
printf("s1:%i\n",s1Len);
printf("s2:%i\n",s2Len);
if ( s1Len > s2Len) {
printf ("s1 este mai mare");
} else {
printf("s2 este mai mare");
}
return 0;
}
int getLength(char *str) {
int i = 0;
while (i < 30 ) {
char c;
c = *(&str[i]);
if (c == 0) {
return i;
}
i++;
}
return i;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment