N
N
Nik_Haker2015-10-04 12:23:04
C++ / C#
Nik_Haker, 2015-10-04 12:23:04

How to write one string into five variables in C?

The goal is this: the user enters five numbers separated by a space. they can be 1 digit, 2 digit, etc. Question: how to write these five numbers not into one char variable, but into five variables (five arrays). Example: the user entered 1 423 3 53 6. variable a=1, b=423, c=3, r=53, e=6, while each element of the array contains one number: b[0]=4, b [1]=2
I write in C, a program without an interface (looks like a command line).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2015-10-04
@2ord

scanf

M
Maxim Moseychuk, 2015-10-04
@fshp

Get the entire string, then use strtok.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question