Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to split a string i have "msg 10 2" into different strings & ints. so instead of having
msg 10 2
I can take each as a seperate parameter can print:
msg
10
2
I use the variable to define a message:
char msg[30] = "msg 10 2";
I then want to take each field as seperate values/parameters.
Thanks
If you know your string will always follow the format string int int, then you could also use sscanf.
Use strtok (which you already tagged) and atoi.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
There is a complex statement in my textbook:
int (*f(float (*)(long),char *))(double);
I want to create an example for illustrating how to use this statement, although I understand the meaning of the statement, it's hard for me to write the example. Can anyone help me?
P.S.: C language.
int (*f(float (*)(long),char *))(double)
f is a function that has 2 parameters of type
float (*)(long), << pointer to function long=>float
char * << string
and returns
(int)(*)(double) << a pointer to a function double=>int
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to print out each integer of an int individually using a for loop. I am doing this because I want to print things in between some of the single ints. So if the number was 4564, I want to print out 4 5 6 4. Is there a quick way to do this?
I know how to do it in java but I am new to C and am not sure.
Something like this shall help
while(num!=0) {
printf("%d", num%10); //your last digit, you can store it in an array of characters as well
num = num/10 ;
}
Note : you've got to reverse the order while using the digits
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a challenge question like "What is your favorite movie?". There could be any question like this. I need last word of the question i.e. movie. without question mark.
Try this
String question = "What is your favorite movie";
String lastWord = question .substring(question .lastIndexOf(" ")+1);
When you select the element containing your challenge question, you can call .getText() (in Java; similar in other languages) to get the text inside. Then, you can use regular expressions or substring utilities in your language to strip out the last word.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
When using C programming language, I have no idea how to put a user input to an array.
I need to get integers from the user in from of:
printf("Enter numbers. Separate each by a comma: ");
How can I put each number into an array?
This is a very helpful link
Also look up this too for clarification on Console.Read & Console.Readline
Difference between Console.Read() and Console.ReadLine()?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
For example, let's say I have the decimal number 10.
I want to be able to go form an integer of 10 to a string of "0a".
How do I do that?
Note: I don't want anything printed out.
You can use sprintf to represent a numeric value in hexadecimal format:
sprintf(buff, "%0.2x\n", 10)
Take also a look at dmckee's comment on int/hexadecimal misunderstanding.