Advertisement
dragonlord119

Assignment1

Mar 18th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.42 KB | None | 0 0
  1. // CommandLineAssignment1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "stdlib.h"
  6. #include "stdio.h"
  7. #include "string.h"
  8. #include "ctype.h"
  9.  
  10. FILE *commandPointer;
  11.  
  12. struct Date
  13.  
  14. {
  15.  
  16. int day;
  17. int month;
  18. int year;
  19.  
  20. };
  21.  
  22. struct Time
  23.  
  24. {
  25.  
  26. int startHour;
  27. int startMinute;
  28. int endHour;
  29. int endMinute;
  30.  
  31. };
  32.  
  33. struct workTime
  34.  
  35. {
  36.  
  37. int employeeID;
  38. struct Date date;
  39. struct Time startTime;
  40. struct Time endTime;
  41.  
  42. };
  43.  
  44. struct workTime employee[20];
  45.  
  46. int main(int argc, char *commandArgument[])
  47.  
  48. {
  49.  
  50. int i = 2;
  51. int j = 0;
  52. char delimiter1[2] = "/";
  53. char delimiter2[2] = ":";
  54. char *commandToken;
  55.  
  56. printf("%s\n", commandArgument[0]);
  57. printf("%s\n", commandArgument[1]);
  58.  
  59. commandPointer = fopen("C:\\Users\\CraigBreathnach\\Desktop\\workLog.txt", "a+");
  60.  
  61. // Section 1
  62.  
  63. while (commandArgument != NULL)
  64.  
  65. {
  66.  
  67. if (!strcmp("/a", commandArgument[i]))
  68.  
  69. {
  70.  
  71. employee[j].employeeID = atoi(commandArgument[i++]);
  72. printf("Employee I.D. : %d\n", employee[j].employeeID);
  73.  
  74. }
  75.  
  76. i++;
  77.  
  78. if ((commandToken = strtok(commandArgument[i], delimiter1)) != NULL)
  79.  
  80. {
  81.  
  82. employee[j].date.day = atoi(commandToken);
  83. printf("Day : %d\n", employee[j].date.day);
  84.  
  85. }
  86.  
  87. if ((commandToken = strtok(NULL, delimiter1)) != NULL)
  88.  
  89. {
  90.  
  91. employee[j].date.month = atoi(commandToken);
  92. printf("Month : %d\n", employee[j].date.month);
  93.  
  94. }
  95.  
  96. if ((commandToken = strtok(NULL, delimiter1)) != NULL)
  97.  
  98. {
  99.  
  100. employee[j].date.year = atoi(commandToken);
  101. printf("Year : %d\n", employee[j].date.year);
  102.  
  103. }
  104.  
  105. i++;
  106.  
  107. if ((commandToken = strtok(commandArgument[i], delimiter2)) != NULL)
  108.  
  109. {
  110.  
  111. employee[j].startTime.startHour = atoi(commandToken);
  112. printf("Start Time (Hour) : %d\n", employee[j].startTime.startHour);
  113.  
  114. }
  115.  
  116. if ((commandToken = strtok(NULL, delimiter2)) != NULL)
  117.  
  118. {
  119.  
  120. employee[j].startTime.startMinute = atoi(commandToken);
  121. printf("Start Time (Minute) : %d\n", employee[j].startTime.startMinute);
  122.  
  123. }
  124.  
  125. if ((commandToken = strtok(commandArgument[6], delimiter2)) != NULL)
  126.  
  127. {
  128.  
  129. employee[j].endTime.endHour = atoi(commandToken);
  130. printf("End Time (Hour) : %d\n", employee[j].endTime.endHour);
  131.  
  132. }
  133.  
  134. if ((commandToken = strtok(NULL, delimiter2)) != NULL)
  135.  
  136. {
  137.  
  138. employee[j].endTime.endMinute = atoi(commandToken);
  139. printf("End Time (Minute) : %d\n", employee[j].endTime.endMinute);
  140.  
  141. }
  142.  
  143. j++;
  144.  
  145. }
  146.  
  147. //if (!strcmp("/a", commandArgument[2]))
  148.  
  149. //{
  150.  
  151. // employee[i].employeeID = atoi(commandArgument[3]);
  152. // printf("Employee I.D. : %d\n", employee[i].employeeID);
  153. // i++;
  154.  
  155. //}
  156.  
  157. //if ((commandToken = strtok(commandArgument[4], delimiter1)) != NULL)
  158.  
  159. //{
  160.  
  161. // employee[i].date.day = atoi(commandToken);
  162. // printf("Day : %d\n", employee[i].date.day);
  163. // i++;
  164.  
  165. //}
  166.  
  167. //if ((commandToken = strtok(NULL, delimiter1)) != NULL)
  168.  
  169. //{
  170.  
  171. // employee[i].date.month = atoi(commandToken);
  172. // printf("Month : %d\n", employee[i].date.month);
  173. // i++;
  174.  
  175. //}
  176.  
  177. //if ((commandToken = strtok(NULL, delimiter1)) != NULL)
  178.  
  179. //{
  180.  
  181. // employee[i].date.year = atoi(commandToken);
  182. // printf("Year : %d\n", employee[i].date.year);
  183. // i++;
  184.  
  185. //}
  186.  
  187. //if ((commandToken = strtok(commandArgument[5], delimiter2)) != NULL)
  188.  
  189. //{
  190.  
  191. // employee[i].startTime.startHour = atoi(commandToken);
  192. // printf("Start Time (Hour) : %d\n", employee[i].startTime.startHour);
  193. // i++;
  194.  
  195. //}
  196.  
  197. //if ((commandToken = strtok(NULL, delimiter2)) != NULL)
  198.  
  199. //{
  200.  
  201. // employee[i].startTime.startMinute = atoi(commandToken);
  202. // printf("Start Time (Minute) : %d\n", employee[i].startTime.startMinute);
  203. // i++;
  204.  
  205. //}
  206.  
  207. //if ((commandToken = strtok(commandArgument[6], delimiter2)) != NULL)
  208.  
  209. //{
  210.  
  211. // employee[i].endTime.endHour = atoi(commandToken);
  212. // printf("End Time (Hour) : %d\n", employee[i].endTime.endHour);
  213. // i++;
  214.  
  215. //}
  216.  
  217. //if ((commandToken = strtok(NULL, delimiter2)) != NULL)
  218.  
  219. //{
  220.  
  221. // employee[i].endTime.endMinute = atoi(commandToken);
  222. // printf("End Time (Minute) : %d\n", employee[i].endTime.endMinute);
  223. // i++;
  224.  
  225. //}
  226.  
  227.  
  228. //// Section 2
  229.  
  230. //if (!strcmp("1010", commandArgument[7]))
  231.  
  232. //{
  233.  
  234. // employee[i].employeeID = atoi(commandArgument[7]);
  235. // printf("Employee I.D. : %d\n", employee[i].employeeID);
  236. // i++;
  237.  
  238. //}
  239.  
  240. //if ((commandToken = strtok(commandArgument[8], delimiter1)) != NULL)
  241.  
  242. //{
  243.  
  244. // employee[i].date.day = atoi(commandToken);
  245. // printf("Day : %d\n", employee[i].date.day);
  246. // i++;
  247.  
  248. //}
  249.  
  250. //if ((commandToken = strtok(NULL, delimiter1)) != NULL)
  251.  
  252. //{
  253.  
  254. // employee[i].date.month = atoi(commandToken);
  255. // printf("Month : %d\n", employee[i].date.month);
  256. // i++;
  257.  
  258. //}
  259.  
  260. //if ((commandToken = strtok(NULL, delimiter1)) != NULL)
  261.  
  262. //{
  263.  
  264. // employee[i].date.year = atoi(commandToken);
  265. // printf("Year : %d\n", employee[i].date.year);
  266. // i++;
  267.  
  268. //}
  269.  
  270. //if ((commandToken = strtok(commandArgument[9], delimiter2)) != NULL)
  271.  
  272. //{
  273.  
  274. // employee[i].startTime.startHour = atoi(commandToken);
  275. // printf("Start Time (Hour) : %d\n", employee[i].startTime.startHour);
  276. // i++;
  277.  
  278. //}
  279.  
  280. //if ((commandToken = strtok(NULL, delimiter2)) != NULL)
  281.  
  282. //{
  283.  
  284. // employee[i].startTime.startMinute = atoi(commandToken);
  285. // printf("Start Time (Minute) : %d\n", employee[i].startTime.startMinute);
  286. // i++;
  287.  
  288. //}
  289.  
  290. //if ((commandToken = strtok(commandArgument[10], delimiter2)) != NULL)
  291.  
  292. //{
  293.  
  294. // employee[i].endTime.endHour = atoi(commandToken);
  295. // printf("End Time (Hour) : %d\n", employee[i].endTime.endHour);
  296. // i++;
  297.  
  298. //}
  299.  
  300. //if ((commandToken = strtok(NULL, delimiter2)) != NULL)
  301.  
  302. //{
  303.  
  304. // employee[i].endTime.endMinute = atoi(commandToken);
  305. // printf("End Time (Minute) : %d\n", employee[i].endTime.endMinute);
  306. // i++;
  307.  
  308. //}
  309.  
  310. //// Section 3
  311.  
  312. //if (!strcmp("2987", commandArgument[11]))
  313.  
  314. //{
  315.  
  316. // employee[i].employeeID = atoi(commandArgument[11]);
  317. // printf("Employee I.D. : %d\n", employee[i].employeeID);
  318. // i++;
  319.  
  320. //}
  321.  
  322. //if ((commandToken = strtok(commandArgument[12], delimiter1)) != NULL)
  323.  
  324. //{
  325.  
  326. // employee[i].date.day = atoi(commandToken);
  327. // printf("Day : %d\n", employee[i].date.day);
  328. // i++;
  329.  
  330. //}
  331.  
  332. //if ((commandToken = strtok(NULL, delimiter1)) != NULL)
  333.  
  334. //{
  335.  
  336. // employee[i].date.month = atoi(commandToken);
  337. // printf("Month : %d\n", employee[i].date.month);
  338. // i++;
  339.  
  340. //}
  341.  
  342. //if ((commandToken = strtok(NULL, delimiter1)) != NULL)
  343.  
  344. //{
  345.  
  346. // employee[i].date.year = atoi(commandToken);
  347. // printf("Year : %d\n", employee[i].date.year);
  348. // i++;
  349.  
  350. //}
  351.  
  352. //if ((commandToken = strtok(commandArgument[13], delimiter2)) != NULL)
  353.  
  354. //{
  355.  
  356. // employee[i].startTime.startHour = atoi(commandToken);
  357. // printf("Start Time (Hour) : %d\n", employee[i].startTime.startHour);
  358. // i++;
  359.  
  360. //}
  361.  
  362. //if ((commandToken = strtok(NULL, delimiter2)) != NULL)
  363.  
  364. //{
  365.  
  366. // employee[i].startTime.startMinute = atoi(commandToken);
  367. // printf("Start Time (Minute) : %d\n", employee[i].startTime.startMinute);
  368. // i++;
  369.  
  370. //}
  371.  
  372. //if ((commandToken = strtok(commandArgument[14], delimiter2)) != NULL)
  373.  
  374. //{
  375.  
  376. // employee[i].endTime.endHour = atoi(commandToken);
  377. // printf("End Time (Hour) : %d\n", employee[i].endTime.endHour);
  378. // i++;
  379.  
  380. //}
  381.  
  382. //if ((commandToken = strtok(NULL, delimiter2)) != NULL)
  383.  
  384. //{
  385.  
  386. // employee[i].endTime.endMinute = atoi(commandToken);
  387. // printf("End Time (Minute) : %d\n", employee[i].endTime.endMinute);
  388. // i++;
  389.  
  390. //}
  391.  
  392. commandPointer = fopen("C:\\Users\\CraigBreathnach\\Desktop\\workLog.txt", "a+");
  393.  
  394. //fputs(commandArgument[2], commandPointer);
  395.  
  396. //itoa(1, employee[0].employeeID, 10)
  397.  
  398. char commandHolder[30];
  399.  
  400. sprintf(commandHolder, "%d", employee[0].employeeID);
  401.  
  402. fputs(commandHolder, commandPointer);
  403.  
  404. return 0;
  405.  
  406. }
  407.  
  408. /*
  409.  
  410. Do not include .exe in command line argument.
  411.  
  412. Mode a+ for ammending file.
  413.  
  414. /p prints from the file, not the data structure.
  415.  
  416. Put search term after /s in command line argument.
  417.  
  418. Type chekcing not available with macros-how to solve?
  419.  
  420. .h files need a \n at the end so they don't concatenate to each other.
  421.  
  422. enum = Enumerator variable, special type of integer that creates a relationship between the variables within it and numbers (first variable is zero, second 1, etc).
  423.  
  424. Can refer to variables via enum name instead of just its number.
  425.  
  426. STATEs = enum name used to check current state of the system. Can call a function to return values, whatever stated in STATES.
  427.  
  428. Names can be anything, just like variables.
  429.  
  430. Let first element = 1, the rest will adjust appropriately.
  431.  
  432. Try not to mess with default values of the enums; if you have to, use known values instead.
  433.  
  434. #include "stdafx.h"
  435. #include "stdlib.h"
  436. #include "stdio.h"
  437. #include "string.h"
  438. #include "ctype.h"
  439. #include "math.h"
  440. #include "time.h"
  441.  
  442. FILE * allocationPointer;
  443.  
  444. typedef struct contact
  445.  
  446. {
  447. char *UserName;
  448. char *firstName;
  449. char *surname;
  450. char *displayName;
  451. char *jobTitle;
  452. char *department;
  453. char *officeNumber;
  454. char *officePhone;
  455. char *mobilePhone;
  456. char *fax;
  457. char *address;
  458. char *city;
  459. char *state;
  460. char *zip;
  461. char *country;
  462.  
  463. };
  464.  
  465. void OpenFile();
  466. void PrintContact(contact *theContact);
  467. void CloseFile();
  468.  
  469. int l = 1;
  470.  
  471. int main()
  472.  
  473. {
  474.  
  475. OpenFile();
  476. printf("\n");
  477. return 0;
  478.  
  479. }
  480.  
  481. void OpenFile()
  482.  
  483. {
  484.  
  485. int n = 5;
  486. int i = 0;
  487.  
  488. allocationPointer = fopen("C:\\Users\\CraigBreathnach\\Desktop\\GY350 College\\CT103 Computer Programming\\Semester 2\\Week 6\\DynamicAllocationFile1.txt", "r");
  489.  
  490. if (allocationPointer == NULL)
  491.  
  492. {
  493.  
  494. printf("Error! The file was not read correctly. Please check that the file path is correct.\n\n");
  495.  
  496. }
  497.  
  498. else
  499.  
  500. {
  501.  
  502. printf("Success! The file was read correctly. The file path is correct.\n\n");
  503.  
  504. }
  505.  
  506. char line[201];
  507.  
  508. for (int i = 0; i <= 1; i++)
  509.  
  510. {
  511.  
  512. fgets(line, 176, allocationPointer);
  513.  
  514. }
  515.  
  516. char delimiter[2] = ",";
  517. char *token;
  518. int j = 0;
  519. int string = 0;
  520.  
  521. while(!feof(allocationPointer))
  522.  
  523. {
  524.  
  525. contact *employeeData[1000];
  526.  
  527. employeeData[j] = (contact *)malloc(sizeof(contact));
  528.  
  529. fgets(line, 201, allocationPointer);
  530.  
  531. if ((token = (strtok(line, delimiter))) != NULL)
  532.  
  533. {
  534.  
  535. string = sizeof(char)*strlen(token) + 1;
  536. employeeData[j]->UserName = (char *)malloc(string);
  537. strcpy(employeeData[j]->UserName, token);
  538.  
  539. }
  540.  
  541. if ((token = (strtok(NULL, delimiter))) != NULL)
  542.  
  543. {
  544.  
  545. string = sizeof(char)*strlen(token) + 1;
  546. employeeData[j]->firstName = (char *)malloc(string);
  547. strcpy(employeeData[j]->firstName, token);
  548.  
  549. }
  550.  
  551. if ((token = (strtok(NULL, delimiter))) != NULL)
  552.  
  553. {
  554.  
  555. string = sizeof(char)*strlen(token) + 1;
  556. employeeData[j]->surname = (char *)malloc(string);
  557. strcpy(employeeData[j]->surname, token);
  558.  
  559. }
  560.  
  561. if ((token = (strtok(NULL, delimiter))) != NULL)
  562.  
  563. {
  564.  
  565. string = sizeof(char)*strlen(token) + 1;
  566. employeeData[j]->displayName = (char *)malloc(string);
  567. strcpy(employeeData[j]->displayName, token);
  568.  
  569. }
  570.  
  571. if ((token = (strtok(NULL, delimiter))) != NULL)
  572.  
  573. {
  574.  
  575. string = sizeof(char)*strlen(token) + 1;
  576. employeeData[j]->jobTitle = (char *)malloc(string);
  577. strcpy(employeeData[j]->jobTitle, token);
  578.  
  579. }
  580.  
  581. if ((token = (strtok(NULL, delimiter))) != NULL)
  582.  
  583. {
  584.  
  585. string = sizeof(char)*strlen(token) + 1;
  586. employeeData[j]->department = (char *)malloc(string);
  587. strcpy(employeeData[j]->department, token);
  588.  
  589. }
  590.  
  591. if ((token = (strtok(NULL, delimiter))) != NULL)
  592.  
  593. {
  594.  
  595. string = sizeof(char)*strlen(token) + 1;
  596. employeeData[j]->officeNumber = (char *)malloc(string);
  597. strcpy(employeeData[j]->officeNumber, token);
  598.  
  599. }
  600.  
  601. if ((token = (strtok(NULL, delimiter))) != NULL)
  602.  
  603. {
  604.  
  605. string = sizeof(char)*strlen(token) + 1;
  606. employeeData[j]->officePhone = (char *)malloc(string);
  607. strcpy(employeeData[j]->officePhone, token);
  608.  
  609. }
  610.  
  611. if ((token = (strtok(NULL, delimiter))) != NULL)
  612.  
  613. {
  614.  
  615. string = sizeof(char)*strlen(token) + 1;
  616. employeeData[j]->mobilePhone = (char *)malloc(string);
  617. strcpy(employeeData[j]->mobilePhone, token);
  618.  
  619. }
  620.  
  621. if ((token = (strtok(NULL, delimiter))) != NULL)
  622.  
  623. {
  624.  
  625. string = sizeof(char)*strlen(token) + 1;
  626. employeeData[j]->fax = (char *)malloc(string);
  627. strcpy(employeeData[j]->fax, token);
  628.  
  629. }
  630.  
  631. if ((token = (strtok(NULL, delimiter))) != NULL)
  632.  
  633. {
  634.  
  635. string = sizeof(char)*strlen(token) + 1;
  636. employeeData[j]->address = (char *)malloc(string);
  637. strcpy(employeeData[j]->address, token);
  638.  
  639. }
  640.  
  641. if ((token = (strtok(NULL, delimiter))) != NULL)
  642.  
  643. {
  644.  
  645. string = sizeof(char)*strlen(token) + 1;
  646. employeeData[j]->city = (char *)malloc(string);
  647. strcpy(employeeData[j]->city, token);
  648.  
  649. }
  650.  
  651. if ((token = (strtok(NULL, delimiter))) != NULL)
  652.  
  653. {
  654.  
  655. string = sizeof(char)*strlen(token) + 1;
  656. employeeData[j]->state = (char *)malloc(string);
  657. strcpy(employeeData[j]->state, token);
  658.  
  659. }
  660.  
  661. if ((token = (strtok(NULL, delimiter))) != NULL)
  662.  
  663. {
  664.  
  665. string = sizeof(char)*strlen(token) + 1;
  666. employeeData[j]->zip = (char *)malloc(string);
  667. strcpy(employeeData[j]->zip, token);
  668.  
  669. }
  670.  
  671. if ((token = (strtok(NULL, delimiter))) != NULL)
  672.  
  673. {
  674.  
  675. string = sizeof(char)*strlen(token) + 1;
  676. employeeData[j]->country = (char *)malloc(string);
  677. strcpy(employeeData[j]->country, token);
  678.  
  679. }
  680.  
  681.  
  682. PrintContact(employeeData[j]);
  683. j++;
  684.  
  685. }
  686.  
  687. CloseFile();
  688.  
  689. }
  690.  
  691. void CloseFile()
  692.  
  693. {
  694.  
  695. fclose(allocationPointer);
  696.  
  697. }
  698.  
  699. void PrintContact(contact *theContact)
  700.  
  701. {
  702.  
  703. printf("User Name %d : %s\nFirst Name %d : %s\nSurname %d : %s\nDisplay Name %d : %s\nJob Title %d : %s\nDepartment %d : %s\nOffice Number %d : %s\nOffice Phone %d : %s\nMobile Phone %d : %s\nFax %d : %s\nAddress %d : %s\nCity %d : %s\nState %d : %s\nZip %d : %s\nCountry %d : %s\n",
  704. l, theContact->UserName, l, theContact->firstName, l, theContact->surname, l, theContact->displayName, l, theContact->jobTitle, l, theContact->department, l, theContact->officeNumber, l, theContact->officePhone,
  705. l, theContact->mobilePhone, l, theContact->fax, l, theContact->address, l, theContact->city, l, theContact->state, l, theContact->zip, l, theContact->country);
  706.  
  707. l++;
  708.  
  709. }
  710.  
  711. #include "stdafx.h"
  712. #include "stdio.h"
  713. #include "stdlib.h"
  714. #include "string.h"
  715. #include "ctype.h"
  716.  
  717. FILE *linkedPointer;
  718.  
  719. struct result
  720.  
  721. {
  722.  
  723. char last[40];
  724. char first[40];
  725. int age;
  726. char email[40];
  727. struct result *next;
  728.  
  729. };
  730.  
  731. result * generateLinkedList();
  732. void searchLinkedList(result * list, int age);
  733.  
  734. int main()
  735.  
  736. {
  737.  
  738. int searchTerm = 0;
  739. int searchOptions = 1;
  740. result * linkedList = NULL;
  741.  
  742. linkedList = generateLinkedList();
  743.  
  744. while (searchOptions != 0)
  745.  
  746. {
  747.  
  748. printf("Please enter a number to search for records based on a person's age. Enter 0 to end the program. \n");
  749. scanf("%d", &searchTerm);
  750.  
  751. if (searchTerm == 0)
  752.  
  753. {
  754.  
  755. printf("You chose option 0. The program will now end. \n");
  756. searchOptions = 0;
  757. exit(0);
  758.  
  759. }
  760.  
  761. else
  762.  
  763. {
  764.  
  765. searchLinkedList(linkedList, searchTerm);
  766.  
  767. }
  768.  
  769. }
  770.  
  771. return 0;
  772.  
  773. }
  774.  
  775. result * generateLinkedList()
  776.  
  777. {
  778.  
  779. int i = 0;
  780. result * startNode = NULL;
  781. result * tempNode = NULL;
  782. result * currentNode = NULL;
  783. char linkedLines[100];
  784. char delim[2] = ",";
  785. char *linkedToken;
  786. int tempToken = 0;
  787.  
  788. linkedPointer = fopen("C:\\Users\\CraigBreathnach\\Desktop\\GY350 College\\CT103 Computer Programming\\Semester 2\\Week 7\\LinkedListFile1.txt", "r");
  789.  
  790. if (linkedPointer == NULL)
  791.  
  792. {
  793.  
  794. printf("Error! The file was not found. Please ensure the file path is correct. \n\n");
  795.  
  796. }
  797.  
  798. else
  799.  
  800. {
  801.  
  802. printf("Success! The file was found. The file path is correct. \n");
  803.  
  804. fgets(linkedLines, 200, linkedPointer);
  805.  
  806. while (!feof(linkedPointer))
  807.  
  808. {
  809.  
  810. tempNode = (result*)malloc(sizeof(result));
  811.  
  812. fgets(linkedLines, 200, linkedPointer);
  813.  
  814. linkedToken = strtok(linkedLines, delim);
  815.  
  816. {
  817.  
  818. if (linkedToken != NULL)
  819.  
  820. {
  821.  
  822. strcpy(tempNode->last, linkedToken);
  823.  
  824. }
  825.  
  826. }
  827.  
  828. linkedToken = strtok(NULL, delim);
  829.  
  830. {
  831.  
  832. if (linkedToken != NULL)
  833.  
  834. {
  835.  
  836. strcpy(tempNode->first, linkedToken);
  837.  
  838. }
  839.  
  840. }
  841.  
  842. linkedToken = strtok(NULL, delim);
  843.  
  844. {
  845.  
  846. if (linkedToken != NULL)
  847.  
  848. {
  849.  
  850. tempToken = atoi(linkedToken);
  851. tempNode->age = tempToken;
  852.  
  853. }
  854.  
  855. }
  856.  
  857. linkedToken = strtok(NULL, delim);
  858.  
  859. {
  860.  
  861. if (linkedToken != NULL)
  862.  
  863. {
  864.  
  865. strcpy(tempNode->email, linkedToken);
  866.  
  867. }
  868.  
  869. }
  870.  
  871. tempNode->next = NULL;
  872.  
  873. if (startNode == NULL)
  874.  
  875. {
  876.  
  877. startNode = tempNode;
  878.  
  879. }
  880.  
  881. else
  882.  
  883. {
  884.  
  885. currentNode = startNode;
  886.  
  887. while (currentNode->next != NULL)
  888.  
  889. {
  890.  
  891. currentNode = currentNode->next;
  892.  
  893. }
  894.  
  895. currentNode->next = tempNode;
  896.  
  897. }
  898.  
  899. }
  900.  
  901. }
  902.  
  903. return startNode;
  904.  
  905. }
  906.  
  907. void searchLinkedList(result * startNode, int age)
  908.  
  909. {
  910.  
  911. result * currentNode = startNode;
  912.  
  913. while (currentNode != NULL)
  914.  
  915. {
  916.  
  917. if (age == currentNode->age)
  918.  
  919. {
  920.  
  921. printf("%s %s\n", currentNode->first, currentNode->last);
  922.  
  923. }
  924.  
  925. currentNode = currentNode->next;
  926.  
  927. }
  928.  
  929. }
  930.  
  931. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement