i have just been messing around with the code you gave me and i keep getting this :
http://i57.photobucket.com/albums/g2...e2k/errors.jpg
im using DEV-C++ now as its way better then pelles C
i have just been messing around with the code you gave me and i keep getting this :
http://i57.photobucket.com/albums/g2...e2k/errors.jpg
im using DEV-C++ now as its way better then pelles C
right after some more messing around with the code i have managed to get the program to run however i get loooadddsssss of errors this is how my string is set out atm
below is a screenshot of alll the rubish i get up however i dont understand and know how to fix itCode:char chart1 [11][11] ={ // Array for the Table and Plot points 'London', 'Bath', 'Cardiff', 'Carlisle', 'Durham', 'Exeter', 'Leeds', 'Norwich', 'Truro', 'York', 'London', '-', '23', '12', '89', '456', '123', '46', '732', '345', '123', 'Bath', '23', '-', '46', '234', '123', '46', '89', '234', '567', '90', 'Cardiff', '12', '46', '-', '767', '456', '46', '234', '123', '732', '35', 'Carlisle', '89', '234', '767', '-', '732', '32', '48', '67', '98', '100', 'Durham', '456', '123', '456', '732', '-', '234', '46', '89', '89', '732', 'Exeter', '123', '46', '46', '32', '234', '-', '123', '46', '123','234', 'Leeds', '46', '89', '234', '48', '46', '123', '-', '46', '89', '19', 'Norwich', '732', '234', '123', '67', '89', '46', '46', '-', '123', '732', 'Truro', '345', '567', '732', '98', '89', '123', '89', '123', '-', '78', 'York', '123', '90', '35', '100', '732', '234', '19', '732', '78', '-'};
[img=http://img265.imageshack.us/img265/6919/lolffsdfdsfsfv6.th.jpg]
right i have every thing into speeh marks ie. "London", however it wont run now it has a problem with
char chart1[10][10][] ={ // Array for the Table and Plot points
it says:
F:\CCCC\asst_new.cpp In function `int main()':
7 F:\CCCC\asst_new.cpp declaration of `chart1' as multidimensional array must have bounds for all dimensions except the first
67 F:\CCCC\asst_new.cpp `chart1' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
for char chart1[10][10][] does [10][10][] mean 10 by 10 grid and what does the other one do?
Here is a correct code:
You were confusing us by packing them into one more subscript, but didn't specify any brackets to specify an actual subscript.Code:char chart1[][11][11] = { { "London", "Bath", "Cardiff", "Carlisle", "Durham", "Exeter", "Leeds", "Norwich", "Truro", "York" }, { "London", "-", "23", "12", "89", "456", "123", "46", "732", "345", "123" }, { "Bath", "23", "-", "46", "234", "123", "46", "89", "234", "567", "90" }, { "Cardiff", "12", "46", "-", "767", "456", "46", "234", "123", "732", "35" }, { "Carlisle", "89", "234", "767", "-", "732", "32", "48", "67", "98", "100" }, { "Durham", "456", "123", "456", "732", "-", "234", "46", "89", "89", "732" }, { "Exeter", "123", "46", "46", "32", "234", "-", "123", "46", "123" "234" }, { "Leeds", "46", "89", "234", "48", "46", "123", "-", "46", "89", "19" }, { "Norwich", "732", "234", "123", "67", "89", "46", "46", "-", "123", "732" }, { "Truro", "345", "567", "732", "98", "89", "123", "89", "123", "-", "78" }, { "York", "123", "90", "35", "100", "732", "234", "19", "732", "78", "-" } };
yep it works thanks a bunch however i cant get it to print out on the screen and look pretty it messes up
im currently using the following to print out on screen
i have b een messing around with the %5s but i keep getting similar outputs 2 thisCode:for(row=0; row<11;row++) // outputs the array in 2 loops { printf("\n\n"); for(col=0;col<=11;col++) { printf("%-6s",chart1[row][col]); } }
http://i57.photobucket.com/albums/g2...tune2k/ddd.jpg
i want it all aligned nicely and looking fab anyone know a better method to achive this ?
Thought I would chime in on this drawn out thread.
Change to
You must compensate for you longest string. They key it so justify it one way or the other, right or left.Code:printf("%-8s",chart1[row][col]);
right my program is comming along nicley and well id like to thank you all for your help i still havent been able to import from a text file but ill learn that soon.
im after an exit command soo when the exit option is selected from the menu it will say somthing like goodbye and then close the program. I am also after a thing where the program has finished running a part of the menu and it will have like Press enter to continue and when enter is pressed it will clear the screen and then call upon the menu method. i know how to call upon the menu part the rest i cant seem to find out how to do it .
How do you end the program now? (Hint: It rhymes with "schmeturn".)
As far as C is concerned, your program is running on a teletype -- there is no concept of a screen that can be cleared. If you happen to be working in a non-teletype environment, there is probably a system-specific command you can use.I am also after a thing where the program has finished running a part of the menu and it will have like Press enter to continue and when enter is pressed it will clear the screen and then call upon the menu method. i know how to call upon the menu part the rest i cant seem to find out how to do it .
whats teletype mean?
kids these days (not that I ever dealt with any myself)
http://en.wikipedia.org/wiki/Teletype
hahaha riggghtttt ive been wondering if it is possible to have a switch case using words want somthing like this
is it possible to do somthing like that or is there an alternative way to do thisCode:char point1[10]; switch[point1] { case "London": blhaaaahahadahaa break; case "Belfast" : vsvsdvdsvsdvudsfv break; case "other place" fcsacdsafadsfkjadshfij break; }
Switch requires an integral type to switch on. However: you happen to have some integers hanging around -- or at least you did a minute ago. chart1[k][0] (for k from 0 to 9) were your city names, correct? Compare your string against those strings (hey hey it's a loop), and then you can switch on k.