I have to include C code into report using listings package. The current options used are presented on the example below. The pointer sign * is in the middle which is not so nice and maybe the general look can be improved. Has anybody appended C code before and can advice some neat solutions?
Kris
Code: Select all
Code, edit and compile here:
\documentclass[a4paper,10pt]{article}\usepackage[utf8x]{inputenc}\usepackage{listings}\begin{document}\lstset{language=C,frame=single,numbers=left,tabsize=2}\begin{lstlisting}#include <stdlib.h>#include <stdio.h>#include <string.h>intmax(int a, int b){if(a>b) return a;else return b;}voidreconstruct(char *x, char *y,int table[strlen(x)+1][strlen(y)+1]){int n=strlen(x),m=strlen(y),i,j,currentChar;int maxlcs=table[n][m];char* lcschar=(char*)malloc((maxlcs+1)*sizeof(char));*(lcschar+maxlcs)='\0';currentChar=0;i=0;j=0;while(currentChar<maxlcs){if( *(x+i) == *(y+j) ){*(lcschar+currentChar)=*(x+i);currentChar++;//printf("%c\n",*(x+i));