Monthly Archive: December 2014

0

Lex Program to Identify Comment Lines

Lex Program to Identify both single line and multi line comments using regular expressions in lex [cc lang=”c”] %{ #include %} %% [/]{1}[/]{1}[a-zA-Z0-9]* printf(“Single Line Comment”); [/]{1}[*]{1}[a-zA-Z0-9]*[*]{1}[/]{1} printf(“MultiLine Comment”); %% main(){yylex();} [/cc]

0

C Program to Compare Strings without Using String Functions

This is the C program to compare strings without using predefined string functions [cc lang=”c”] #include char string1[100],string2[100]; int flag=1,len1=0,len2=0; main() { int res; printf(“Enter String-1n”); gets(string1); printf(“Enter String-2n”); gets(string2); while(string1[len1]!=’’){len1++;} while(string2[len2]!=’’){len2++;} res=compare(string1,string2); if...