Skip to content

Commit e3fe98a

Browse files
committed
Added revstr w/o creating a new one
1 parent 5f1c522 commit e3fe98a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tmp.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33

44
#define VARSIZE(var) ((char*)(&var+1) - (char*)(&var)) /*MTA: & operator returns a pointer to the variable. +1 takes you beyond the end of the variable. char* typecasting helps you count.*/
55

6+
/* Write a macro to read from a HW register */
7+
8+
#define HWREG(addr) (*(volatile unsigned int*)(addr))
9+
10+
#define REGADDR 0xAB230000
11+
12+
/*
13+
//to load the value, declare variable v
14+
15+
unsigned int v = HWREG(REGADDR);
16+
17+
//To store to this hw reg
18+
19+
HWREG(REGADDR) = value;
20+
*/
21+
22+
/***********************************************************/
23+
624
/*Reverse a number*/
725

826
int reversedigit(int num)
@@ -162,6 +180,21 @@ char* strrev (char* s, int size)
162180
}
163181
/**********************************************************************/
164182

183+
/* Reverse a string w/o creating a new one*/
184+
185+
void revstr (char* s, int len)
186+
{
187+
char temp;
188+
for (int i=0; i<len/2; i++)
189+
{
190+
temp = s[i];
191+
s[i] = s[len-1-i];
192+
s[len-1-i] = temp;
193+
}
194+
}
195+
196+
/*********************************************************************/
197+
165198
/*Find first duplicate element in Array*/
166199

167200
int FirstDup (int* a, int l)

0 commit comments

Comments
 (0)