That was supposed that code runs in a cycle as that most probably is. Note
the 'count' variable that is not defined in the original snippet. And, yes,
you are right the 'finalLine' in the second snippet should be incremented
somehow. However, the intent of the snippet was to just show difference
between char and string - it is far less efficient so it's hard to believe
that somebody is going to use it.
Also, probably, strcpy( finalLine, theLine ) will do.
And, if you like any weird implementations:
char temp,theLine[1000],finalLine[1000];
for(...){
temp=theLine[count];
memcpy(finalLine+count,&temp,sizeof temp);
Quote:
}
Vladimir Kuznetsov
Brainbench C Programming "Most Valuable Professional"
Quote:
> The two code snippets you recommend are not equivalent. Either the first
> should read
> finalLine[0] = theLine[count];
> finalLine[1] = 0;
> or the second should read
> char temp[2],theLine[1000],finalLine[1000];
> temp[1]=0
> temp[0]=theLine[count];
> strcpy(finalLine + count, temp);
> --
> With best wishes,
> Igor Tandetnik
> > finalLine[count]=theLine[count];
> > or
> > char temp[2],theLine[1000],finalLine[1000];
> > temp[1]=0
> > temp[0]=theLine[count];
> > strcpy(finalLine,temp);
> > Vladimir Kuznetsov
> > Brainbench C Programming "Most Valuable Professional"
Quote:
> > > Hello,
> > > I have the following:
> > > char temp,theLine[1000],finalLine[1000];
> > > temp=theLine[count];
> > > strcpy(finalLine,temp); file://I get an error here
> > > How do I go about doing the above?
> > > Thanks!
> > > Sent via Deja.com http://www.deja.com/
> > > Before you buy.