Ok, here's my code as below but I am getting errors about missing ';' before the ')'.
I've worked in vb.net and no such problem would exist in vb.
Anyway, I don't really know if what I've written up to now is correct or not as the program is incomplete, but the thing is I can't test how I'm doing up to now due to the missing semi-colons problem.
#include "stdafx.h"
#include "stdio.h"
#include <conio.h>
int _tmain(int argc, _TCHAR* argv[])
{
int n = 0;
scanf("%d", &n);
int *a = 0;
a = newint[n];
int m = 0;
scanf("%d", &m);
int *b = 0;
b = newint[m];
int temp, i;
scanf("%d", &a[n]);
scanf("%d", &b[m]);
if (n < m)
{
for (i=0, i <m, i++)
{
temp = i;
for (i=0, i<n, i++)
{
if (a[i] = b[temp]);
{
if (a[i+1] = b[temp+1]);
{
printf("there are 2 consecutive elements in the a and b arrays");
}
}
}
}
}
a = 0;
b = 0;
getch();
return 0;
}
for (i=0, i <m, i++){
Becomes for (i=0; i <m; i++){
same for the other for loop. if (a[i] = b[temp]){
becomes if (a[i] == b[temp]){
same for the other if.
1 2
scanf("%d", &a[n]);
scanf("%d", &b[m]);
Segmentation Fault. Or you ask n/m times for a single value, or you don't need at all to "new" the arrays.
1 2
scanf("%d", &a[n-1]);
scanf("%d", &b[m-1]);
removes the segfaults if you want to run your code and see what it does.
Hmm, I just googled about dynamic declaration of array size and got that code somewhere but it seems I've gotten it wrong, I can compile it even without those two fixes that you mentioned, I had to fix the previous errors. But what happens after compiling the program is that I scan the n&m values, I input the a[n] elements one by one but I can't put the b[m] elements as the program goes straight to the getch() code.
This is the problem:
This code only asks for ONE number to store into a[n-1], and ONE number into b[m-1].
So you need to LOOP from 0 to n-1, and to store each value correctly.