Hello All,

I just want to ask what this programme does. Actually i know what it does, i just wanna know the exact operation of it.

char *u ; //declare the string
char k;
unsigned int x; // declare integer
int i; 
u = " University " ;
k = u[0];

ASC0_uwGetData() ; //wait to get data
x = ASC0_uwGetData() ; //get character to the variable

if(x=='u')

{
for(i=0;k!=0; i++) // Read-dynamic way
{

k =u[i] ;
while(ASC0_ubTxBufFree() == 0) {} //wait untill buffer is not busy
ASC0_vSendData(k); //send Data

}
}

OK what i dont get is the for loop. what does it do exactly with the string(z=p)? Is it trying to read the word using the dynamic way? How does it do that?
The programme is perfectly working. it reads the u character when its pressed from the keyboard and the extract the word university.. I know its very simple but i'm a beginner...so pls help me!!!!

The function appears to be sending some characters someplace, such as across a socket or serial port.

>>what does it do exactly with the string(z=p)?
I don't see that in your post

The function appears to be sending some characters someplace, such as across a socket or serial port.

>>what does it do exactly with the string(z=p)?
I don't see that in your post

First of all, Thank you for your reply!!

This programme receives the u keystroke and then it extracts the word university on the hyperterminal. (I am programming a microchip connected with a pc via serial)

Sorry about the mistake.. it should be k=u

The for loop does it all. The thing is since k takes the first block on u's string(array) why is there an increment counter used (i++) and then what does the k=u does...??

As you can see i am a very beginner... :)

i is a counter that is used to index or iterate throug the array. On each loop iteration the value of i is incremented by one so that the program is referencing the next character in the string. See this table for how I got the values of k.

i      u[i]      k
0     ' '         32 // ascii decimal value of a space
1     U           85
2     n          110
3     i          105
...

If I were writing that code snipped I would have simplified it like this, which does not use k at all.

for(i=0;  u[i] != 0; i++) // Read-dynamic way
{
      while(ASC0_ubTxBufFree() == 0) {} //wait untill buffer is not busy
      ASC0_vSendData( u[i] ); //send Data

}

First post the code for ASC0_uwGetData ,etc as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.