The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
All input appreciated
Discuss All input appreciated in the C Programming forum on Dev Shed. All input appreciated C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 29th, 2012, 07:46 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 2
Time spent in forums: 27 m 10 sec
Reputation Power: 0
|
|
|
All input appreciated
Hello, I've been studying C language for a week and it is my 1st language - so I'm a total newbee. Anyhow, I went through some of the basic commands and deicded to make a little program that is going to help me in my work. Here is the gist of the program:
I would want to put 2 arreys of values, have them compare each other and then have the program printf the values that don't match- eg if one of the arreys has a value that the other one doesn't contain.
(I have also read somewhere how to make a .txt file in which the values can be written, but I guess there is no need to over-complicate things at first, just having a functional program is enough)
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
int base1[]= {1,2,3,4};
int base2[]= {1,2,3,4,5,6,7,8,9};
int x;
int y;
x = 0;
y = 0;
(x = 0, x <4 , x++);
if ( base1[x]!= base2[y])
{(y < 9, y++);}
if ( base1[x] = base2[y])
{printf("\n.\n");}
if (y = 9)
{printf ("the number "base1[x]" has no match");}
return 0;
system("PAUSE");
}
Beside several warnings, the debbuger pops out this error as well
'expected ')' before base1' on line 31.
All help appreciated, thank you
|

December 29th, 2012, 09:07 AM
|
 |
Contributing User
|
|
|
|
In other words, you want the union of the two sets "minus" the intersection of the sets. (set difference of the union and intersection).
Your printf function needs a format specifier, like this:
printf ("the number %d has no match",base1[x]);
You have another construct that looks as if you intended a for statement but forgot to write `for'.
(x = 0, x <4 , x++);
You'll need to replace the semi-colon at the end of the line with brace to make a block statement including the code you want in the for loop.
Perhaps you'd rather learn executable Iverson notation rather than c?
Code:
1 2 3 4 (union less intersect) 1 2 3 4 5 6 7 8 9
5 6 7 8 9
__________________
[code] Code tags[/code] are essential for python code!
|

December 30th, 2012, 05:08 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 2
Time spent in forums: 27 m 10 sec
Reputation Power: 0
|
|
|
Hello and thank you for your time.
I have made the changes you suggested and it has eliminated all but 1 error. I will try and figure it out on my own and if I can't, it just means I'm not ready to make the project at this point and time.
As for looking into other languages, my current focus is more on getting a solid understanding of C, then on making any one specific program.
Once again, thank you for the input and the suggestions.
Cheers
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|