Author Topic: quick C question  (Read 1227 times)

Stryker

  • VIP
  • Member
  • ***
  • Posts: 1,258
  • Kudos: 41
quick C question
« on: 1 July 2003, 14:00 »
I'm having a problem with this:

Code: [Select]

It gives the output:

Code: [Select]

I think there is a problem with my while statement. I did it with for just fine, I'm just thinking I can do it with while too.

I probably look stupid, but I'm trying to brush up on some C skills.

[ July 01, 2003: Message edited by: Stryker ]


Stryker

  • VIP
  • Member
  • ***
  • Posts: 1,258
  • Kudos: 41
quick C question
« Reply #1 on: 1 July 2003, 14:10 »
bah, nm i was being stupid. it's 2am though. what do you expect?

You can't program at 2am without pizza and beer.

suselinux

  • Member
  • **
  • Posts: 711
  • Kudos: 30
quick C question
« Reply #2 on: 1 July 2003, 14:18 »
you can't do anything at 2am without pizza and beer

solo

  • Member
  • **
  • Posts: 344
  • Kudos: 1
    • http://www.komodolinux.org/
quick C question
« Reply #3 on: 2 July 2003, 10:34 »
Actually, I find ET to be extremely easy even without beer and pizza... however, I need vast amounts of drugs at 2 am in the morning
Komodoware, moving Linux to your desktop.
http://www.komodoware.com/

jtpenrod

  • VIP
  • Member
  • ***
  • Posts: 675
  • Kudos: 105
quick C question
« Reply #4 on: 3 July 2003, 14:05 »
quote:
while (x=0,x!=argc,x++)
The commas are the problem: these should be semi's.
____________________________________
Live Free or Die: Linux

"There: now you'll never have to look at those dirty Windows anymore"
      --Daffy Duck
Live Free or Die: Linux
If software can be free, why can't dolphins?

Stryker

  • VIP
  • Member
  • ***
  • Posts: 1,258
  • Kudos: 41
quick C question
« Reply #5 on: 3 July 2003, 14:22 »
quote:
Originally posted by jtpenrod:
The commas are the problem: these should be semi's.


That's correct for the for() function. I figured it all out, I was using while() way wrong. Now to figure out how to take some chars out of a string and use them.

char *buf1="abcdefg";
how do we make buf2="cdef"?

flap

  • Member
  • **
  • Posts: 1,268
  • Kudos: 137
quick C question
« Reply #6 on: 3 July 2003, 19:36 »
strncpy(buf2, buf1 + 2, 4);
"While envisaging the destruction of imperialism, it is necessary to identify its head, which is none other than the United States of America." - Ernesto Che Guevara

http://counterpunch.org
http://globalresearch.ca