Jump to content

Quick question about arrays

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Hunterios

Hunterios

    Newbie

  • Members
  • Pip
  • 3 posts
Hello,can someone tell me how i can start taking characters from a certain cell(ex. s[5]) and not from beggining

Thanks in advance

#2
ksemeks

ksemeks

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
I presume you run your array through a loop.
So you change the index to 5, instead of 0.
...
int index;
for (index = 5; index < sizeof(sArray)/sizeof(int); index++) { //code .. }

// d-_-b+

#3
Hunterios

Hunterios

    Newbie

  • Members
  • Pip
  • 3 posts
I'm working on c,i didnt rly get ur answer :D
I got a char array and i wanna put 100 strings in it
When i get the 1st string i wanna stop to do some checks,is there any way so i can continue getting strings at the point i stopped?

#4
ksemeks

ksemeks

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
You can make an in int variable which will hold the number of the element which you wish to check/so your stuff with it.
Once you finished, you continue with the number which you stored in that int variable.
Hope you understood what am i trying to say here.
// d-_-b+

#5
Hunterios

Hunterios

    Newbie

  • Members
  • Pip
  • 3 posts
Its not what i'm looking for,i wanna know if there is any way i can start reading from a certain cell with scanf or any other input command
ex.
i'm using getchar(s) to fill s array,how i can make it start from 5th cell and not from 0?
My enlgish are quite bad so i cant express it like i want ;/ thanks for your time anyway :D

#6
ksemeks

ksemeks

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
You can use 'scanf("%s", &stringArray[index])' , or stringArray[index] = getchar() .

One idea that comes into mind is getchars(s), and then copy those value into another array from the 5th element and so on.
Or something like that.
// d-_-b+




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users