Ok I see. Thank you. The aim of the exercise is to implement some other features and functions and then to optimize these to the max (memory wise and runtime wise). That's why I was so concerned...
Type: Posts; User: petz_e
Ok I see. Thank you. The aim of the exercise is to implement some other features and functions and then to optimize these to the max (memory wise and runtime wise). That's why I was so concerned...
Hi,
I'm trying to learn C, and part of an exercise is to read what the user types in and print it in the console character-by-character.
#include <string.h>
#include <stdlib.h>
#include...
Well, I am a bit stuck here. Here is what I want to do.
I have an integer 'n' and I want to isolate every single digit and put them into an array of ints.
Example: n = 1024
t[0] = 4
t[1] = 2...
In fact, it is a dynamic sized array with integer values between 0 and 9. I just put constant values here for the post. I think '0'+c[i] should work for my example, I still need to test it.
Patrick
Hi,
I want to convert an integer to a char:
(...)
char *converttostr( my_struct a )
{
char *c;
c = (char *)malloc(20 * sizeof(char));
No, it's ok. I got it working now :) Thanks again
Patrick
OK, the input string doesn't have to be composed of consecutive digits, but this should not matter.
Thanks for the replies and for the help.
Patrick
But what does the -'0' mean? Is this used to make the conversion?
And just to get things right, if the string is entered with a scanf command, you also have to remove the \n character at the end,...
Here is my code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct {
int signe;
int size;
Hello,
This is my first post in this forum.
I have a string s in the following format: -1234567890
Now I need to strip the '-' and convert every single digit into an int and place it into an...