Hi, I'm not a C programmer. Could someone please code the following request for me in C?
I have a list of 3 numbers. 3, 6, 7
I want to scan through this list and count the number of odd...
Type: Posts; User: metros
Hi, I'm not a C programmer. Could someone please code the following request for me in C?
I have a list of 3 numbers. 3, 6, 7
I want to scan through this list and count the number of odd...
Yes, good idea, I see where you're coming from. Also I can then refer to the values in the intArray when need be, such as intArray[2]
Is this a ridiculous way of doing it?
for(i=0; i<3; i++)
{
Thanks for this.
Forgetting the conversion for a moment, I'm confused how with a loop each value in the array can be assigned to different variables
Hi, I want to extract the contents of a char array of size 4 into separate variables of type integer.
I guess given array[i] I traverse it? But I'm not sure how to populate the variables
ultimately what I want to do is take each input form the command line and put them into their own variable. At the moment I'm playing around with printf to see what is actually contained in the array.
I changed it a bit to this.........
line[i] = getchar();
while(line[i] != EOF) {
line[i] = getchar();
}
Ah I see. But why does having c=getchar() before print make 1 disappear?
Hi. When I run the following program....... and enter in for example 12345
why does it print out 2345. Where is 1 gone?
int main ()
{
int c;
I want to ignore white spaces
I've written the following rough piece of code.......
for(i=0; i<2 && c!=' '; i++)
{
if(c != ' ')
{
c=getchar();
That makes sense. I'm going to give that a try. Thanks. I'll get back if I'm struggling
Hmmm, it's a bit limited to be honest. Perhaps this illustrates how restrictive getchar is
Hi. I want to enter a number of chars on a command line. For example....... a b c 4 6
How do I take these valuesin and treat them as seperate values?
I want to use getchar instead of getch or...
If you imagine a list
textfile1
textfile123
textfile&
file&
file2&
Hi I tested what you said on the following code, however nothing has changed....
int getline(char s[], int lim)
{
int c, i;
for (i=0; i<lim-1 && (c=getchar())!=EOF &&...
Can anyone shed any light on this please? :)
Sorry! Here's the funciton........
int getline(char s[], int lim)
{
int c, i;
for (i=0; i<lim-1 && (c=getchar())!=EOF && c!='\n'; ++i)
s[i] = c;
Hi, how do I found out if a name ends with '&' or at worse contains '&'. Below is a function that gets an inputted line (or name). Is it possible to add functionality to this function that does what...
If anyone could point me in the direction of simple examples of how to accept input from either the command line or other files I'd appreciate it, thanks.
Final question on this........
So file1 needs to be set up (ie coded with input parameters or whatever) to take in the output?
Yep will do, thanks
Thanks for that information.
If I wanted to use the following command....
ls -Fa | file1 (where file1 is an exe)
what should happen? This is off topic, sorry about that
Thanks for the reply. I just realized that 'redirecting' is possibly the wrong word to use for the | symbol. Anyway I 'd like to stick to using '|' . Any advice would be helpful, thanks ;)
Hi, I want to redirect the output of the 'ls' command into a file. For example "ls -Fa | ./newfile.text"
However I am getting the 'permission denied' error. Am I going about this the correct way?