Original Post
I have a problem.
I''m writing a program that allows you to sort 10 names that you''ve entered, and as a sorting algorythm I use bubblesort.
But now I also need to swap data from 1 position to another, but I keep getting all these errors. Could someone help me ?
it is as following:
char n[10][255] is a global variable to store the names in.
in the swap function, I have the following:
char *tmp_n = &n[n1];
n[n1] = n[n2];
n[n2] = tmp_n;
tmp_n is the temporary var.
n1 and n2 are the numbers of wich items are about to be swapped:
For example: If you want to swap n[5] and n[6], the syntax for the swap_items function is as following: swap_items(5,6).
When I compile I get the following output: (I use MSVC++ 6.0)
--------Configuration: SortTest - Win32 Debug--------------------
Compiling...
main.cpp
E:\School\SortTest\main.cpp(49) : error C2440: ''initializing'' : cannot convert from ''char (*)[255]'' to ''char *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\School\SortTest\main.cpp(51) : error C2106: ''='' : left operand must be l-value
E:\School\SortTest\main.cpp(52) : error C2440: ''='' : cannot convert from ''char *'' to ''char [255]''
There are no conversions to array types, although there are conversions to references or pointers to arrays
Error executing cl.exe.
SortTest.exe - 3 error(s), 0 warning(s)
CAN SOMEONE HELP ME WITH THIS ?????
pascal