Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: bad pointer error when I read a class object with CString member Pin
Stefan_Lang12-Jun-15 0:13
Stefan_Lang12-Jun-15 0:13 
QuestionWindows 8.1 TouchScreen panning does not scroll window for MFC Scrollview or Win32 apps Pin
bob169727-Jun-15 7:10
bob169727-Jun-15 7:10 
AnswerRe: Windows 8.1 TouchScreen panning does not scroll window for MFC Scrollview or Win32 apps Pin
bob1697220-Jun-15 3:31
bob1697220-Jun-15 3:31 
Questionlinked list in C Pin
a random user7-Jun-15 4:28
a random user7-Jun-15 4:28 
AnswerRe: linked list in C Pin
Chris Losinger9-Jun-15 4:55
professionalChris Losinger9-Jun-15 4:55 
Questionneed help with linked structs at C language Pin
a random user5-Jun-15 23:57
a random user5-Jun-15 23:57 
AnswerRe: need help with linked structs at C language Pin
Richard MacCutchan6-Jun-15 0:29
mveRichard MacCutchan6-Jun-15 0:29 
GeneralRe: need help with linked structs at C language Pin
a random user6-Jun-15 0:56
a random user6-Jun-15 0:56 
well i first created the code to work on the main but somehow somethign went wrong when i tried putting the codes in functions
<
every time i go to the function insertAtEnd but at the second loop of the while it just says error

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

struct numberNode
{
int number;
struct numberNode* Next;
};

typedef struct numberNode numStruct;


numStruct* createSong(int numbers)
{
numStruct* newSong = (numStruct*)malloc(sizeof(numStruct));
if (newSong)
{
newSong->number = numbers;
newSong->Next = NULL;
}
return newSong;
}



void insertAtEnd(numStruct** firstNode, numStruct* newNode)
{
numStruct* currNode = *firstNode;

// if the linked list is empty
// should put the new node as the first
if (!currNode)
{
*firstNode = newNode;
newNode->Next = NULL;
}
else
{
while (currNode->Next) // problem at the second loop
{
currNode = currNode->Next;
}

currNode->Next = newNode;
newNode->Next = NULL;
}
printf("\n\n");
}


numStruct* AddSongs(numStruct* anchorNode, numStruct* newNode)
{

int count = 0;
int numbers;

printf("\nPlease enter numbers and at the end enter -999\n");

do
{
count++;
_flushall();
numbers = 0;

printf("\n\n%d.\n\nnumber: ", count);
scanf("%d",&numbers);

if (numbers != -999)
{

newNode = createSong(numbers);
insertAtEnd(&anchorNode, newNode);
}
}
while (numbers != -999);
printf("\n\n");
}




int main(void)
{
numStruct* anchorNode = NULL;
numStruct* newNode;
AddSongs(&anchorNode, &newNode);

system("PAUSE");
}
GeneralRe: need help with linked structs at C language Pin
Frankie-C6-Jun-15 6:42
Frankie-C6-Jun-15 6:42 
GeneralRe: need help with linked structs at C language Pin
a random user6-Jun-15 7:03
a random user6-Jun-15 7:03 
GeneralRe: need help with linked structs at C language Pin
Frankie-C6-Jun-15 7:12
Frankie-C6-Jun-15 7:12 
GeneralRe: need help with linked structs at C language Pin
a random user6-Jun-15 7:20
a random user6-Jun-15 7:20 
GeneralRe: need help with linked structs at C language Pin
a random user6-Jun-15 7:25
a random user6-Jun-15 7:25 
GeneralRe: need help with linked structs at C language Pin
Frankie-C7-Jun-15 5:33
Frankie-C7-Jun-15 5:33 
GeneralRe: need help with linked structs at C language Pin
a random user7-Jun-15 6:32
a random user7-Jun-15 6:32 
GeneralRe: need help with linked structs at C language Pin
Frankie-C7-Jun-15 7:38
Frankie-C7-Jun-15 7:38 
QuestionRe: need help with linked structs at C language Pin
David Crow8-Jun-15 3:20
David Crow8-Jun-15 3:20 
AnswerRe: need help with linked structs at C language Pin
a random user21-Jun-15 9:37
a random user21-Jun-15 9:37 
QuestionThreading Issues Pin
ForNow5-Jun-15 5:09
ForNow5-Jun-15 5:09 
AnswerCAsyncSocket notifications Onconnect OnSend owned by main thread Pin
ForNow7-Jun-15 2:15
ForNow7-Jun-15 2:15 
GeneralRe: Threading Issues Pin
Albert Holguin8-Jun-15 16:21
professionalAlbert Holguin8-Jun-15 16:21 
GeneralRe: Threading Issues Pin
ForNow8-Jun-15 17:21
ForNow8-Jun-15 17:21 
Questionwhy 4 twice Pin
Member 117446405-Jun-15 4:15
Member 117446405-Jun-15 4:15 
AnswerRe: why 4 twice Pin
David Crow5-Jun-15 4:19
David Crow5-Jun-15 4:19 
AnswerRe: why 4 twice Pin
k50545-Jun-15 5:35
mvek50545-Jun-15 5:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.