Tom Gunn 1,164 Practically a Master Poster

That sounds like a good beginner's exercise. You should totally write a program like that. :)

Tom Gunn 1,164 Practically a Master Poster

Functions cannot be nested in C++. They have to be at global, namespace, or class scope. You should be able to fix the error by moving the definition of CreateAllNodes() so that it comes before the definition of main().

Tom Gunn 1,164 Practically a Master Poster

Newbies not using code tags are a huge issue for us, and we finally made some successful progress

It must have been a sad state of affairs before that progress, because almost none of the new members use code tags in the C and C++ forums now.

Tom Gunn 1,164 Practically a Master Poster

To position the triangle is as easy as printing out as many spaces as the position for each line:

for (int x = 0; x < position; ++x) cout.put(' ');

Clipping the triangle is only a bit harder. Calculate the current position and if it exceeds the width, break your printing loop for that line:

for (int x = 0; x < twidth; ++x)
{
    if (x + position >= swidth) break;
    else cout << x + 1;
}
Tom Gunn 1,164 Practically a Master Poster

Assignment statements do not work at the global scope. Put it in the main() function:

#include <iostream>

using namespace std;

int anArray[3];

int main()
{
	anArray[0] = 7;

	return 0;
}

It is also a good idea to avoid global variables, but that is a lesson for another day. :)

Your_mum commented: Problem Sovled!! : ] +1
Tom Gunn 1,164 Practically a Master Poster

so no one has solved it still............

If anyone has bothered, they will not post the code. It is counterproductive and against Daniweb's rules to help people cheat on their homework.

Tom Gunn 1,164 Practically a Master Poster

1) Can't: #include "stdafx.h" - fatal error:file or directory not found.

I would recommend that you forget stdafx.h exists. It is easier in my opinion to start with an empty project and use the standard headers than to work with VC++'s precompiled headers. The other project types all start out with the precompiled headers, which is why I recommend always using an empty project. :)

2) For some reason, I can include the <iostream> file, but not "iostream.h".

The reason is iostream.h is not a standard C++ header, but iostream is. iostream.h was part of C++ before it was standardized, and the standard replaced it with the current iostream. You should be using iostream and not iostream.h in new code.

3) Array Problem -

That snippet is fine. Can you post more? The error might be coming from somewhere else.

Tom Gunn 1,164 Practically a Master Poster

If you compile with -Wall you should've seen the warning warning C4700: uninitialized local variable 'a' used and that's because class A doesn't have a constructor.

-Wall is not a switch in VC++, but that warning is thrown on the default warning level, and the "internal exception" I get when running the code also tells me the same thing. a was not initialized. I think this is a case of not reading the provided error messages. It is a bad habit. I end up working harder on end user support because they like to close error dialogs without reading them. ;)

Tom Gunn 1,164 Practically a Master Poster

But still I am getting the same error as above

I am sorry, I should have been more specific. Change the name everywhere. Your compiler should be giving you line numbers in the error, so you can find where you need to make changes. In the code you posted, maintemp1 = new temp1(&maintemp2); will not work for the same reason. temp1 is a template and needs a list of template arguments:

maintemp1 = new temp1<test3>(&maintemp2);

Every time you use the name of a template, you need to provide a template argument list too.

Tom Gunn 1,164 Practically a Master Poster

It's by far the best compiler/debugger on the market.

Best is subjective. I do not think M$'s compiler is the best, but it is competitive with the other top compilers. The IDE and debugger are the biggest selling points for VS, in my opinion.

I rather use the VS 2008 complier myself but AFAIK it is NOT standard (eg. it will comply exactly in another IDE/complier/etc).

As I said before, VS 2008 is a C89/95 compliant compiler. You said you do not care about C99, so I do not understand why you keep insisting that VC is not standard. If you have specific complaints about VC that make it not standard in your opinion, I can address them. But until then, it is just going to be back and forth with no progress.

Dave Sinkula commented: You're really selling VS quite well. I'm the closest ever to trying it out. :icon_razz: +13
Tom Gunn 1,164 Practically a Master Poster

How to pass array of pointers to structures using functions in C?

Pointers are very regular. Once you know the basics, you can apply those basics to any level of indirection and everything will work the same way. Start with the two basic rules:

  1. A pointer variable is declared by appending * to the type.
  2. A pointer value is acquired by using the & unary operator.

Obviously things like this follow those rules, and you can find tons of examples in books or online:

int obj = 5;
int* p = &obj; /* p is a pointer to int and refers to obj's adress */

Pointers are used to pass large objects around without copying them, to dynamically manage blocks of memory, and to simulate pass-by-reference semantics. Pass-by-reference basically means that changes to a function parameter will affect the original object and not just a copy of it.

The two rules are recursive within limits, so you can add another level of indirection and get a pointer to a pointer:

int obj = 5;
int* p = &obj;
int** pp = &p; /* &&obj will not work because &obj is not an object with an address */

Pointers to pointers are usually used to simulate pass-by-reference semantics on pointers or to manage dynamic multidimensional arrays. The lesson to take away from this is pointers are just another type, and you can add a level of indirection to almost any type.

Arrays are an …

tux4life commented: Another great post :) +6
Tom Gunn 1,164 Practically a Master Poster

Yet VS 2008's C compiler is different than a standard C compiler.

It conforms to C89, along with the C95 addendum. How is that not good enough? ;) Like I said, all of the commonly used compilers are equally solid with C89. In my experience gcc is no better or worse in C89 mode than VC in C89 mode. Gcc is a great compiler, and I am not trying to convince you to use VC, but your statements really do suggest either ignorance or emotional attachment to gcc.

Tom Gunn 1,164 Practically a Master Poster
temp1 *maintemp1;

temp1 is a template class. The error means exactly what it says, and you should add a template argument list. Maybe temp1<test3> ?

Tom Gunn 1,164 Practically a Master Poster

Exactly. I want the best complier that is compatible with C89.

Then any of the popular compilers will meet that condition. You will not find a C89 compiler that is noticeably better than the rest.

Well if im "picky picky", then I invite you to go ahead and buy the complier for me and donate to me.

Please forgive me for the offensive remark. I will remember that your humor mechanism is in need of repair and avoid similar remarks in the future. :icon_rolleyes:

Tom Gunn 1,164 Practically a Master Poster

Then how can I set in VS 2008 to use gcc and gdb as the debugger

I am not qualified to answer that since I have not done it. But I know it can be done, so you can probably find instructions with a web search.

Simply because it conforms to the regular standards of C and it is free.

Every C compiler I know of in regular use conforms to C89, and C89 is still the defacto standard for C. The only C compiler I know of that conforms completely to C99 is Comeau. Gcc does not yet conform to C99, and unless they have fixed it, many of the custom extensions conflict with equivalent C99 features and make conformance either very fragile or impossible. It is in a better state than VC, where Microsoft has said they have no plans for conforming to C99, but partial conformance is still a portability issue.

1: It is not free
2: It is not the easiest to install so that automatically makes it lose points

Picky picky. ;) I still think Code::Blocks is your best bet, but I also think Visual C++ is the best IDE hands down.

Tom Gunn 1,164 Practically a Master Poster

when you load executable does it load directly in RAM or it gets loaded in hdd and sent to pages to hdd

Executables are loaded into memory. Memory could mean either physical memory or virtual memory. If you open more programs than the physical memory can handle, the computer will start paging in and out of virtual memory. The whole point of virtual memory is to extend the physical memory without anyone being the wiser. The cost of that extension is speed, which brings me back to the statement of anything that uses memory can potentially cause thrashing.

Tom Gunn 1,164 Practically a Master Poster

I also need help with push. I couldn't figure out how to complete the definition or routine for it.

It looks like you are using a two way linked list for the implementation. If that is the case, push is no harder than the other operations. Push() is the inverse of Inject() just as Pop() is the inverse of Eject(). You posted in the C forum, so I will give you example code in C:

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct Node
{
    int value;
    struct Node* prev;
    struct Node* next;
} Node;

typedef struct Deque
{
    size_t size;
    Node* front;
    Node* rear;
} Deque;

Deque* NewDeque()
{
    Deque* d = malloc(sizeof *d);

    if (d)
    {
        d->size = 0;
        d->front = d->rear = NULL;
    }

    return d;
}

void DeleteDeque(Deque* d)
{
    Node* p = d->front;
    Node* next;

    while (p)
    {
        next = p->next;
        free(p);
    }

    free(d);
}

int Push(Deque* d, int value)
{
    Node* new = malloc(sizeof *new);

    if (new)
    {
        new->value = value;
        new->prev = NULL;
        new->next = d->front;

        if (!d->front) d->rear = new;
        else d->front->prev = new;

        d->front = new;
        ++d->size;

        return 1;
    }
    else return 0;
}

int Inject(Deque* d, int value)
{
    Node* new = malloc(sizeof *new);

    if (new)
    {
        new->value = value;
        new->prev = d->rear;
        new->next = NULL;

        if (!d->rear) d->front = new;
        else d->rear->next = new;

        d->rear = new;
        ++d->size;

        return 1;
    }
    else return 0;
}

int Pop(Deque* d, int* value)
{
    if (d->front)
    {
        Node* saved = d->front; …
Tom Gunn 1,164 Practically a Master Poster

maybe its a compiler issue.

It is a normal result of stream I/O in C. The problem is that there is still a character left in the stream after calling scanf(), and getchar() eats it without blocking. The IDE you are using probably closes the window after main() returns, so the window goes away. Calling getchar() is supposed to stop that, but it only works if the stream is clean when getchar() is called.

You can clean the stream with repeated calls to getchar() until '\n' is found. This will produce the right behavior if the stream is not clean, and it will only require an extra [Enter] to be typed if the stream is already clean:

#include <stdio.h>

int main()
{
    int age;

    printf("Please enter your age:");
    scanf("%d", &age);

    if(age<100)
    {
        printf("You are pretty young!!!\n");
    }
    else
    {
        if(age==100)
        {
            printf("You are old\n");
        }
        else
        {
            if(age>100)
            {
                printf("You are really old\n");
            }
        }
    }

    /* clean the stream */
    while (getchar() != '\n') {}

    /* pause */
    getchar();

    return 0;
}
Tom Gunn 1,164 Practically a Master Poster

One thing that causes thrashing is when physical memory is filled up and spills over into virtual memory. Virtual memory is disk based instead of RAM based, so it is much slower to access data stored in virtual memory. Anything that uses RAM can potentially cause that form of thrashing.

let's say we load many files at once wouldn't that cause thrashing ?

It depends on how the files are loaded. If they are large and completely stored in memory all at once, that could easily cause thrashing. If they are small or the program loading them is smart enough to conserve memory, thrashing is not as likely.

Tom Gunn 1,164 Practically a Master Poster

I cant use Visual Studio 2008 (which Id like to) as it uses it own compiler.

Most IDEs, including Visual Studio, can be configured to use a different compiler. I am wondering why you think gcc is the best C compiler. It is certainly good, but not really much better than the other popular alternatives, in my opinion. I would say the best is Comeau because it conforms to the latest standards of both C and C++. The only problems with Comeau are it is not free, and it is only a front-end compiler, so it is not as easy as install and go.

If you will not consider anything but gcc, I think Code::Blocks is your best option. MinGW comes packaged with gcc as the default compiler, installation is a snap, and the IDE is pretty good.

Tom Gunn 1,164 Practically a Master Poster

Strings in C are terminated by a '\0' character, but there is no magic that stops loops on it. Nothing stops you from walking past that character if the loop does not account for it. Change your loop to something like this and it will stop in the right place:

for(int i = 0; i < 10 && user_input[i] != '\0'; ++i)
{
    /* print user_input[i] */
}

This will make sure your loop stops when '\0' is found or the limit of the array is reached. To be strictly safe in C++, you should also limit cin when reading the string:

cin >> setw(10) >> user_input;

In C you can do the same thing with scanf():

scanf("%9s", user_input);
Tom Gunn 1,164 Practically a Master Poster

Is it true that some compilers require void before main ?

No. Any compiler that claims to compile C is required to allow a return value of int from main(). A return of void from main() is an extension that only some compilers allow. These two definitions of main(), and anything equivalent, are the only correct and portable options:

int main()
{
    /*...*/
}
int main(int argc, char* argv[])
{
    /*...*/
}

Why this error ?

I cannot say without seeing more code. It is probably in the wrong place, judging from the misplacement of clrscr() in your first post.

Tom Gunn 1,164 Practically a Master Poster

So at one point I felt that this has more of C rather than C++ and thats what I told OP because this is a C++ forum.

That is kind of like saying a woman is a little bit pregnant. The code is either C or not C. If there are any features of C++ that cause a C compiler to choke, the code is not C. Anyway, I will not send the thread any more off topic. ;)

Tom Gunn 1,164 Practically a Master Poster

There is nothing C++ in this code apart from "using namespace std","cout","bool".

You have a strange idea of what is and is not C++. The headers are all messed up, but if those are fixed to match what is actually used, it is all C++. Here are the right headers:

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cctype>
Tom Gunn 1,164 Practically a Master Poster

I'm surprised GUI app programmers get use to it, it is really confusing.

Once you understand it, you can crank out code like that without thinking. One thing visual designers do is abstract all of that code away so that the programmer can drag and drop controls, then add the meat functionality without worrying as much about the scaffolding.

I know this sound lame but, why not VB?

It is not uncommon to write the GUI in a convenient language, then glue that together with a back end written in a different language. VB on the front end and C++ on the back end works well.

Does C++ really compensate with its power but havig to swallow all that GUI tough coding?

VB is just as bad. The only difference is the visual designer hides the GUI tough coding from a VB programmer and the tutorial you are looking at does not assume that a visual designer is available for C++. You are kind of comparing apples to oranges. ;)

Tom Gunn 1,164 Practically a Master Poster

char and char* are two different types. You should audit your code looking for mistakes with pointers, because I see more than just that mismatch in terms of pointer problems.

Tom Gunn 1,164 Practically a Master Poster

If the problem is that answer is 0, it is likely that you are dividing everything away. Because int does not have a precision, anything past the radix will be truncated. 1/2 is 0.5 as double, but 0 as int because the .5 is cut off.

Tom Gunn 1,164 Practically a Master Poster

does it takes a lot of time to get to the "real word" (i know you like that expression) apps?

It is hard to draw a line between "real world" and "not real world". I think of real world apps as useful programs written with the intent of being useful. I cannot stress enough that a GUI is not the difference between real world and not real world.

Are the apps made by some IDEs similar to the VB one?

Sometimes. In the end it is all just code. If the IDE helps you write that code, more power to you. There is no magic involved in writing a GUI. You still create objects, call methods, and all of that other stuff that you are learning now.

How? How?!

Try it out and see. I assume you are on a Windows computer, so you can follow the tutorials here and create your own GUI. But I will warn you that if you are not very comfortable with C++, you will end up struggling with both the language and a graphics library at the same time.

Tom Gunn 1,164 Practically a Master Poster

how hard is the step from making console application to real world apps?

Many real world apps are also console apps, so the only real difference is that those GUI apps use a GUI library to make a pretty looking interface on top of the same kind of stuff that you would write in a console app. Of course real world apps also do a lot more than the practice programs you are writing now to get comfortable with the language. ;)

why i don't usually see questions relating that in any c++ forums?

The questions on forums are usually very focused. They might be a small part of a much larger program, but for the most part I think the majority of questions are coming from the people who are still learning basics and not the people who are experienced and trying to write a real world app. The experienced programmers can usually answer their own questions without asking for help by doing research.

it's like hard to believe that what i'm learning now will lead me to creating real and useful apps

It is also hard to believe that a few simple principles of sound can be put together into something incredible like this. :)

Tom Gunn 1,164 Practically a Master Poster

what is the time cost of the actual re balancing of the tree

It depends on how the algorithms are implemented, but ideally for insertion the cost of rebalancing is constant. Only one part of the tree will ever be out of balance and at most two rotations will bring it back into balance. For deletion there could be one rebalance step for each node along the search path, so the number of rebalances on deletion is O(log(n)).

why is this ignored?

Rebalancing is a constant time operation and time complexities remove constant values. Instead of saying that AVL deletion is O(log(n) + m) where m is the time a rebalance takes, the m is trimmed away as an unnecessary part and the result is simplified to O(log(n)).

Tom Gunn 1,164 Practically a Master Poster
main()

If you do not specify a return type for main(), it does not mean you are exempt from returning a value. This feature is called implicit int. It means that if a data type is expected but not provided, int is assumed. So these two definitions of main() are exactly the same and the return statement is required for both:

main()
{
    return 0;
}
int main()
{
    return 0;
}

Relying on implicit int is not a good practice because the latest C standard removes the feature. Your code will not compile as C99, and that adds one more thing that needs to be changed to make it conform.

char STR1[100];

Names in all upper case are usually reserved for macros. It is up to you whether or not to use that convention, but people reading your code will be confused that STR1 is an array object and not a macro.

clrscr();

clrscr() is a non-standard function from conio.h, but you did not include conio.h. I would not recommend anything from conio.h, but like the naming conventions, it is up to you whether or not to take that advice. The portability police will not haul you away if you choose to use unportable stuff. :)

gets (STR1);

gets() is always unsafe and cannot be made safe through good coding practices. Never use it, because there is always a risk of array overflow. The safe alternative to gets() is fgets():

Tom Gunn 1,164 Practically a Master Poster

So to conclude: in standard C there's no straightforward way to find out how many subscripts you assigned a value to.

A second variable with the number of used items is straightforward. This approach is no different from a vector in C++, except for a little extra work in maintaining the count. As long as the array is filled in a non-random manner, the count variable is easy to use:

#include <stdio.h>

int main()
{
    int a[10];
    int n = 0;
    int x;

    fputs("Enter a list of integers: ", stdout);
    fflush(stdout);

    while (n < 10 && scanf("%d", &a[n]) == 1) ++n;

    printf("There are %d integers in the list:\n", n);

    for (x = 0; x < n; ++x) printf("%d\n", a[x]);

    return 0;
}

If the array is filled at random indexes the count variable will still work, but to avoid accessing uninitialized indexes there needs to be an empty value to mark the element as empty. With that in place an algorithm similar to strlen() can also count the non-empty elements:

#include <stdio.h>
#include <ctype.h>

#define SZ 'Z'-'A'+1

int arraylen(int a[], size_t sz)
{
    int n = 0;
    int x;

    for (x = 0; x < sz; ++x)
    {
        if (a[x]) ++n;
    }

    return n;
}

int main()
{
    int a[SZ] = {0};
    int c;
    int x;

    fputs("Enter a string: ", stdout);
    fflush(stdout);

    while ((c = getchar()) != EOF)
    {
        c = toupper(c);

        if (isalpha(c)) ++a[c-'A'];
    }

    printf("There are %d unique letters\n", arraylen(a, SZ));

    for (x = 0; x …
Tom Gunn 1,164 Practically a Master Poster

I cant use while ...

i should do it with if -else only ..

any suggestions ??

If the number of substances in the file is fixed, you can unroll the loop because the logic inside the loop is what you want for getting the right output. The loop itself just makes the code shorter and easier to follow.

Tom Gunn 1,164 Practically a Master Poster

I think your approach is better if you add line breaks, but you can probably get the right output like this:

open file
let n be 1

while more substances
    read a substance

    if substance freezes
        print name + " freezes"
    else if substance boils
        print name + " boils"
    else
        continue

    if n++ is even
        print line break
    else
        print " and "
end while

close file
Tom Gunn 1,164 Practically a Master Poster

i tried to solve it but i couldnt get the same input ..

Post your try and we can help you make it better.

Tom Gunn 1,164 Practically a Master Poster

It's ancient and there's just so many reasons to use an up-to-date compiler, can't be bothered listing them.

For several obvious reasons Tom Gunn :

1)Because it is sub standard.
2)Uses all the extinct headers and commands.
3)It is not according to the c99 standards.
4)void main is valid in it.
5)The blue screen irritates a lot...
And loads other stuff.........

That is what I thought you were going to say. Please check your facts before turning people off to a good compiler. Turbo C++ has an up-to-date version from around 2006. As far as I know, it conforms to the standard. If you are going to bash Turbo C++, at least make it clear what version you are attacking and why.

Tom Gunn 1,164 Practically a Master Poster

Don't use Turbo C

Why not?

Tom Gunn 1,164 Practically a Master Poster

I do not understand what you want. The argument to system() is the same thing you would type in a console window. If you want to move files in Windows or DOS, the console command might look like this:

C:\>move c:\windows\temp\*.* c:\temp

The string you pass to system() for that same command is exactly the same:

system("move c:\windows\temp\*.* c:\temp");

Maybe if you explain what you are trying to use the system() function for, I can help more.

Tom Gunn 1,164 Practically a Master Poster

An example might help:

#include <iostream>
#include <cstdlib>

int main()
{
    std::size_t sz;

    std::cout << "Enter a size: ";

    if (std::cin >> sz)
    {
        int* p = new int[sz];

        for (int x = 0; x < sz; ++x) p[x] = rand();
        for (int x = 0; x < sz; ++x) std::cout << p[x] << '\n';

        delete[] p;
    }
}
Tom Gunn 1,164 Practically a Master Poster

i dont know what is -pedantic mean

Here is a quote from the online manual for gcc:

-pedantic

Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++. For ISO C, follows the version of the ISO C standard specified by any -std option used.

i think with compliance to ansi standards
but the latest compilers are ISO do we still need to stick to
ansi

Gcc probably uses -ansi as a historic artifact, but it really does mean ISO C90 and not ANSI C89:

-ansi

In C mode, support all ISO C90 programs. In C++ mode, remove GNU extensions that conflict with ISO C++.

Functionally there is not really much difference between ANSI C89 and ISO C90. Alternatively, you can use -std= to get the same effect and also for C99 conformance:

// ISO C90
gcc -Wall -std=c89 -pedantic test.c

// ISO C99
gcc -Wall -std=c99 -pedantic test.c

There are a bunch of other options. You can read about them here.

Tom Gunn 1,164 Practically a Master Poster

The algorithm is the same as with a binary tree. The only difference is you loop through the vector to find a matching key and then loop through the links and recursively traverse each one in turn.

Tom Gunn 1,164 Practically a Master Poster

Linux uses '\n' for line breaks but Windows uses "\r\n". That should not matter because the compiler should recognize and convert to and from system specific representations. It can make a difference if you open the file as binary because binary mode will disable the text conversions.

I have not used Cygwin, but it might also be because it is a compatibility layer and if there is a disconnect somewhere it might not be converting line breaks the way it should.

Tom Gunn 1,164 Practically a Master Poster

You differentiate between logical and actual links. Logical links are part of an n-ary node, but represented with actual binary links. If you can do that, you will be able to figure out how to move when doing any traversal. Red black trees do this well, if you need a real world example. Red links are logical links and black links are actual links, and they come together to represent a 2-3 tree with a binary structure.

Tom Gunn 1,164 Practically a Master Poster

string is not a good name because that name is already used for the std::string class. At the very least you should put your class in a namespace. I do not have Dev-C++, so I cannot reproduce your error, but I would guess that is the cause of the error.

There are also other errors. One that might be confusing is that this is a pointer, so you cannot use the . operator like that to get to members. Use the -> operator instead.

Tom Gunn 1,164 Practically a Master Poster

It looks OK, but that is with a few assumptions. Can you post a complete example that fails when it should not?

Tom Gunn 1,164 Practically a Master Poster
Tom Gunn 1,164 Practically a Master Poster

I want to say yes, but just to be sure, can you give an example of what you mean by each of those?

Tom Gunn 1,164 Practically a Master Poster

Replace this part of your header:

#define N_GLAC=22;
#define latGLAC[22] = {43.96875, 45.34375, 45.34375, 46.15625, 46.21875, 46.28125, 46.78125, 46.84375, 46.84375, 46.84375, 46.90625, 47.46875, 47.53125, 47.78125, 47.78125, 48.03125, 48.03125, 48.59375, 48.78125, 48.78125, 48.96875, 51.46875};
#define lonGLAC[22] = {-110.84375, -121.65625, -121.71875, -121.46875, -121.53125, -121.84375, -121.71875, -121.65625, -121.71875, -121.78125, -121.78125, -120.84375, -121.21875, -123.65625, -123.71875, -121.09375, -121.15625, -113.71875, -121.34375, -121.84375, -114.21875, -117.78125};

With this:

#define N_GLAC 22
double latGLAC[22] = {43.96875, 45.34375, 45.34375, 46.15625, 46.21875, 46.28125, 46.78125, 46.84375, 46.84375, 46.84375, 46.90625, 47.46875, 47.53125, 47.78125, 47.78125, 48.03125, 48.03125, 48.59375, 48.78125, 48.78125, 48.96875, 51.46875};
double lonGLAC[22] = {-110.84375, -121.65625, -121.71875, -121.46875, -121.53125, -121.84375, -121.71875, -121.65625, -121.71875, -121.78125, -121.78125, -120.84375, -121.21875, -123.65625, -123.71875, -121.09375, -121.15625, -113.71875, -121.34375, -121.84375, -114.21875, -117.78125};

There were two problems. First is you were defining N_GLAC the wrong way for a macro. Macros do not use the = sign to assign a value, and they do not end with a semicolon. Second, you were trying to define arrays with macro syntax. A header is nothing special when it comes to defining objects. You do it the same way as any global variable.

vaishnavi_5 commented: I tried to const uint16_t Cos12bit[361] = {4000,....}; with 361 elements in main.h but it shows error as duplicate definition in main.o & stm32f30x.o +0
Tom Gunn 1,164 Practically a Master Poster

Is that simply what I must do or is there a way to make it so the two functions have the same name?

There is a way, but it means writing a dispatch function or macro and all of the complexity involved. It is pretty simple if you are working with a small number of known functions, but something generic will probably be hairy. It is easier and probably better overall to avoid all of those moving parts and just use different names for each function. ;)

Tom Gunn 1,164 Practically a Master Poster

It is impossible to help you without seeing the code that your compiler balks at and the errors that are thrown. Please post all of your code, or a small self-contained subset that has the error, and post all of the errors you get.